Skip purging when LiteSpeed is not in front of Drupal

Fixes #3609034.

The purger now checks whether LiteSpeed serves the request before it sends a PURGE. When LiteSpeed is not detected, the invalidations are marked as succeeded with a debug log entry, so the queue drains and no error reaches the admin pages. Drush and cron reuse the last result seen on a web request. $settings['lscache_purger_assume_litespeed'] = TRUE; keeps the current behaviour.

Testing instructions

Unit tests, two of them new:

vendor/bin/phpunit modules/contrib/lscache/tests/src/Unit

On 1.3.x: 142 tests, all passing. testInvalidateSkipsWhenLiteSpeedNotDetected and testInvalidateAssumeLiteSpeedSettingOverridesDetection cover the new path.

Manual check on a site served by Apache or nginx, with lscache_purger enabled:

drush p:queue-add tag:node:1
# open any admin page in the browser: no "LSCache purge aborted" error
drush state:get lscache_purger.litespeed_detected   # false
drush p:queue-work --finish
drush p:queue-volume                                # 0 items
drush watchdog:show --type=lscache_purger           # "LSCache purge skipped" at debug level

On a site behind LSWS the same steps store true and the PURGE goes out as before.

AI Compliance

🤖 Generated with the help of an LLM, reviewed and approved by me.

Merge request reports

Loading
Loading