-
Notifications
You must be signed in to change notification settings - Fork 117
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.