litespeedtech / litespeedtech/lscache_wp
[BUG] getimagesize() on missing image causes LSAPI deadlock and full site outage (PHP 8.3.24, LSCache 7.4)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 257
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
Environment
PHP version: 8.3.24
LiteSpeed Cache for WordPress: 7.4
Web Server: OpenLiteSpeed (OLS)
We're experiencing critical issues where the site goes down due to LSAPI deadlocks caused by the LiteSpeed Cache plugin.
When the plugin attempts to call getimagesize() on a missing image (typically under /wp-content/uploads/), the following error appears repeatedly in the logs:
`[STDERR] PHP Warning: getimagesize(https://example.com/wp-content/uploads/2021/10/example_file.png): Failed to open stream: HTTP request failed! in /folder/example.com/wp-content/plugins/litespeed-cache/src/media.cls.php on line 899
`
This is immediately followed by OpenLiteSpeed logs like:
`No request delivery notification has been received from LSAPI application, possible dead lock`
This stalls PHP workers, causes ExtConn timed out while processing messages, and ultimately results in the entire WordPress site becoming unresponsive.
Root Cause
It appears that getimagesize() is used without a prior check to confirm the existence or availability of the image URL. When the image is missing or the HTTP call fails, the process hangs and blocks the PHP worker without timing out gracefully.
Expected Behavior
The plugin should verify that the image exists before attempting to process or cache it. Failing that, it should handle the error gracefully without crashing the PHP worker or causing LSAPI deadlocks.
Suggested Fix
Add a check before getimagesize():
```
if (@get_headers($url)[0] !== 'HTTP/1.1 404 Not Found') {
$info = getimagesize($url);
}
```
Or at least wrap the getimagesize() call in a suppression and error-handling block to prevent hanging on 404s.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/media.cls.php around line 899 and trace the caller that invokes getimagesize() for upload URLs. Reproduce the missing-image case using the reported PHP and OpenLiteSpeed environment, then verify that failed image access is handled without stalling PHP workers or causing LSAPI deadlocks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100