wp-media / imagify-plugin

Speed up your website with lighter images without losing quality.
https://imagify.io
71 stars 25 forks source link

Imagify incompatibility with WordPress 5.8 Block Widget Editor #571

Closed piotrbak closed 3 years ago

piotrbak commented 3 years ago

Before submitting an issue please check that you’ve completed the following steps:

Describe the bug We have a fatal error when trying to edit legacy widgets when Imagify and Yoast are enabled.

To Reproduce Steps to reproduce the behavior:

  1. Make sure you have some widgets assigned to sidebars
  2. Install WordPress 5.8 (https://wordpress.org/plugins/wordpress-beta-tester/)
  3. Install and activate Imagify and Yoast
  4. Visit the widgets section of the WordPress or check the WP Debug log
  5. See error

Expected behavior No fatal errors

Screenshots image

Additional context Full fatal error:

[11-Jun-2021 13:34:14 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function get_current_screen() in /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-content/plugins/imagify/inc/3rd-party/yoast-seo.php:13
Stack trace:
#0 /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/class-wp-hook.php(303): _imagify_dequeue_yoastseo_script('')
#1 /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(NULL, Array)
#2 /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/plugin.php(470): WP_Hook->do_action(Array)
#3 /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/script-loader.php(2015): do_action('wp_print_script...')
#4 /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/class-wp-hook.php(303): wp_print_head_scripts('')
#5 /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(Array, Array)
#6 /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/plugin.php(470): WP_Hook->do_action(Array)
#7 /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/general-template.php(3 in /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-content/plugins/imagify/inc/3rd-party/yoast-seo.php on line 13

I believe that WordPress shouldn't display errors there anyway, so here's the Github issue on Gutenberg repo: https://github.com/WordPress/gutenberg/issues/32624

Backlog Grooming (for WP Media dev team use only)

mostafa-hisham commented 3 years ago

I followed the steps and the error didn't show or appear in the log file I think they fixed it in WP core please check this https://github.com/WordPress/gutenberg/issues/32624

iCaspar commented 3 years ago

Indeed, these are probably related issues. That said, #567 seems to be happening on WP versions prior to 5.8. Adding the guard to check that current_screen() is indeed loaded may still be in order to prevent a fatal error in any case. See #582.