Fatal error related to a path structure issues in a Windows environment
Describe the bug After updating to the latest version of WP Rocket, the customer is having a Fatal error when accessing internal subsites (multisite environment).
The issue appears on a Windows server and in a multisite setup.
The Fatal error is related to path structure issues in a Windows environment
Error log :
[20-Apr-2025 12:18:06 UTC] PHP Warning: preg_grep(): Compilation failed: unrecognized character follows \ at offset 12 in D:\xxxxxxx\wwwroot\wp\wp-content\plugins\wp-rocket\inc\functions\files.php on line 1146
[20-Apr-2025 12:18:06 UTC] PHP Fatal error: Uncaught TypeError: reset(): Argument #1 ($array) must be of type array, bool given in D:\xxxxxxx\wwwroot\wp\wp-content\plugins\wp-rocket\inc\functions\files.php on line 1147
Stack trace:
#0 D:\xxxxxxx\wwwroot\wp\wp-content\plugins\wp-rocket\inc\functions\files.php(1147): reset()
#1 D:\xxxxxxx\wwwroot\wp\wp-content\plugins\wp-rocket\inc\Engine\Common\Cache\FilesystemCache.php(128): rocket_rrmdir()
#2 D:\xxxxxxx\wwwroot\wp\wp-content\plugins\wp-rocket\inc\Engine\Media\Lazyload\CSS\Admin\Subscriber.php(99): WP_Rocket\Engine\Common\Cache\FilesystemCache->full_clear()
#3 D:\xxxxxxx\wwwroot\wp\wp-includes\class-wp-hook.php(324): WP_Rocket\Engine\Media\Lazyload\CSS\Admin\Subscriber->clear_background_css_with_upgrade()
#4 D:\xxxxxxx\wwwroot\wp\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters()
#5 D:\xxxxxxx\wwwroot\wp\wp-includes\plugin.php(517): WP_Hook->do_action()
#6 D:\xxxxxxx\wwwroot\wp\wp-content\plugins\wp-rocket\inc\admin\upgrader.php(21): do_action()
#7 D:\xxxxxxx\wwwroot\wp\wp-includes\class-wp-hook.php(324): rocket_upgrader()
#8 D:\xxxxxxx\wwwroot\wp\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters()
#9 D:\xxxxxxx\wwwroot\wp\wp-includes\plugin.php(517): WP_Hook->do_action()
#10 D:\xxxxxxx\wwwroot\wp\wp-admin\admin-ajax.php(45): do_action()
#11 {main} thrown in D:\xxxxxxx\wwwroot\wp\wp-content\plugins\wp-rocket\inc\functions\files.php on line 1147
To Reproduce Steps to reproduce the behavior:
- On a Windows server
- On a multisite setup
- Update the WP Rocket plugin
- See error on accessing the subsite
Expected behavior No fatal error should occur.
The customer added this recommendation:
Recommended Permanent Fix: We suggest that dynamic input used in preg_grep() should be sanitized or wrapped with preg_quote() to avoid regex failures. This should especially be considered for multisite installations running on Windows environments.
Additional context
- Ticket: https://secure.helpscout.net/conversation/2920990956/556820?viewId=273761
- Slack discussion: https://group-onecom.slack.com/archives/C08F4M3BBJL/p1745831325858639
hi, any updates on this? We’re aiming to stay current with the latest versions and would appreciate it if this could be prioritized to avoid falling behind. thanks!