wp-media / imagify-plugin

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

Fatal error with update in edge case #866

Open wordpressfan opened 3 months ago

wordpressfan commented 3 months ago

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

Describe the bug

PHP Error During Imagify Plugin Update from version 2.1.3.1 to 2.2.0.1

The user got the following PHP error when tried to update the Imagify plugin through the Smart Plugin Manager. When attempting manual updates, they do not observe the error, and the process completes without any issues. However, it's crucial to note that the error did briefly appear during the SPM update process and was also recorded in the logs. Fortunately, after the update concluded, the site resumed normal operation.

PHP error:
Uncaught Error: Class "Imagify\Stats\OptimizedMediaWithoutWebp" not found in /xx/content/live/xx/wp-content/plugins/imagify/classes/Plugin.php:58 Stack trace: #0 /xx/content/live/xx/wp-content/plugins/imagify/inc/main.php(29): Imagify\Plugin->init() #1 /xx/content/live/xx/wp-includes/class-wp-hook.php(324): imagify_init('') #2 /xx/content/live/xx/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #3 /xx/content/live/xx/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /xx/content/live/xx/wp-settings.php(506): do_action('plugins_loaded') #5 /xx/content/live/xx/wp-config.php(120): require_once('/nas/content/li...') #6 /xx/content/live/xx/wp-load.php(50): require_once('/xx/content/li...') #7 /xx/content/live/xx/wp-admin/admin-ajax.php(22): require_once('/xx/content/li...') #8 {main} thrown on line 58 in file wp-content/plugins/imagify/classes/Plugin.php

After doing some investigation I found: We refactored this plugin.php file and renamed this class OptimizedMediaWithoutWebp to be OptimizedMediaWithoutNextGen so what I can think of is there was a background process running inside Imagify in the same time of update so it was a lucky shot and as the customer mentioned, the site was live and wasn't affected with this error.

We created this issue to keep track of update fatal errors and go from here.

To Reproduce Steps to reproduce the behavior: We don't have solid steps, this happens randomly.

Expected behavior No error should happen with update.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Acceptance Criteria (for WP Media team use only) Clear instructions for developers, to be added before the grooming