wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
702 stars 219 forks source link

PHP Fatal error: Uncaught TypeError: strtoupper() #7084

Open MiKeF05 opened 3 weeks ago

MiKeF05 commented 3 weeks ago

Describe the bug There is a fatal php error in the server log.

PHP Fatal error: Uncaught TypeError: strtoupper(): Argument #1 ($string) must be of type string, null given in /var/www/{page}/public_html/wp-content/plugins/wp-rocket/inc/Engine/Optimization/LazyRenderContent/Frontend/Processor/Dom.php:140\nStack trace:\n#0 /var/www/{page}/public_html/wp-content/plugins/wp-rocket/inc/Engine/Optimization/LazyRenderContent/Frontend/Processor/Dom.php(140): strtoupper()\n#1 /var/www/{page}/public_html/wp-content/plugins/wp-rocket/inc/Engine/Optimization/LazyRenderContent/Frontend/Processor/Dom.php(107): WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Processor\Dom->add_hash_to_element()\n#2 /var/www/{page}/public_html/wp-content/plugins/wp-rocket/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller.php(150): WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Processor\Dom->add_hashes()\n#3 /var/www/{page}/public_html/wp-content/plugins/wp-rocket/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller.php(123): WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Controller->add_hashes()\n#4 /var/www/{page}/public_html/wp-content/plugins/wp-rocket/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber.php(45): WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Controller->add_hashes_when_allowed()\n#5 /var/www/{page}/public_html/wp-includes/class-wp-hook.php(324): WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Subscriber->add_hashes_when_allowed()\n#6 /var/www/{page}/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters()\n#7 /var/www/{page}/public_html/wp-content/plugins/wp-rocket/inc/Engine/Optimization/Buffer/Optimization.php(100): apply_filters()\n#8 [internal function]: WP_Rocket\Engine\Optimization\Buffer\Optimization->maybe_process_buffer()\n#9 /var/www/{page}/public_html/wp-includes/functions.php(5427): ob_end_flush()\n#10 /var/www/{page}/public_html/wp-includes/class-wp-hook.php(324): wp_ob_end_flush_all()\n#11 /var/www/{page}/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()\n#12 /var/www/{page}/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()\n#13 /var/www/{page}/public_html/wp-includes/load.php(1280): do_action()\n#14 [internal function]: shutdown_action_hook()\n#15 {main}\n thrown in /var/www/{page}/public_html/wp-content/plugins/wp-rocket/inc/Engine/Optimization/LazyRenderContent/Frontend/Processor/Dom.php on line 140

There is also an internal server error in the console which is related to the php error.

Image

MiKeF05 commented 2 weeks ago

Any news on this topic would be appreciated

joejoe04 commented 1 week ago

Related (internal use only): https://secure.helpscout.net/conversation/2764174394/523559

Seems we should first check to make sure this value is a string before proceeding: https://github.com/wp-media/wp-rocket/blob/e5bca6673a3669827f3998edebc0c785210fe561/inc/Engine/Optimization/LazyRenderContent/Frontend/Processor/Dom.php#L145C7-L145C46