wp-media / imagify-plugin

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

Added a try catch for the fatal error #725

Open CrochetFeve0251 opened 1 year ago

CrochetFeve0251 commented 1 year ago

Fix the issue due to the Runtime exception raised by Action Scheduler when the tables are not present.

Fix #720

Mai-Saad commented 1 year ago

@CrochetFeve0251 thanks for the PR. Can see the error on the PR with the following steps: (can you please check) precondition: manually delete AS tables from database 1- fresh install and activation of imagify 2- add keys => error appeared although it's valid 3- open imagify settings https://new.rocketlabsqa.ovh/wp-admin/options-general.php?page=imagify => error in logs `[24-May-2023 14:52:49 UTC] PHP Fatal error: Uncaught RuntimeException: Unable to claim actions. Database error. in /var/www/new.rocketlabsqa.ovh/htdocs/wp-content/plugins/imagify-plugin/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php:938 Stack trace:

0 /var/www/new.rocketlabsqa.ovh/htdocs/wp-content/plugins/imagify-plugin/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php(799): ActionScheduler_DBStore->claim_actions()

1 /var/www/new.rocketlabsqa.ovh/htdocs/wp-content/plugins/imagify-plugin/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_HybridStore.php(221): ActionScheduler_DBStore->stake_claim()

2 /var/www/new.rocketlabsqa.ovh/htdocs/wp-content/plugins/imagify-plugin/inc/Dependencies/ActionScheduler/classes/ActionScheduler_QueueRunner.php(157): ActionScheduler_HybridStore->stake_claim()

3 /var/www/new.rocketlabsqa.ovh/htdocs/wp-content/plugins/imagify-plugin/inc/Dependencies/ActionScheduler/classes/ActionScheduler_QueueRunner.php(136): ActionScheduler_QueueRunner->do_batch()

4 /var/www/new.rocketlabsqa.ovh/htdocs/wp-includes/class-wp-hook.php(308): ActionScheduler_QueueRunner->run()

5 /var/www/new.rocketlabsqa.ovh/htdocs/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()

6 /var/www/new.rocketlabsqa.ovh/htdocs/wp-includes/plugin.php(565): WP_Hook->do_action()

7 /var/www/new.rocketlabsqa.ovh/htdocs/wp-cron.php(188): do_action_ref_array()

8 {main}

thrown in /var/www/new.rocketlabsqa.ovh/htdocs/wp-content/plugins/imagify-plugin/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php on line 938` @piotrbak please advise if we need to recreate the tables :pray:

Note: we won't be able to delete the plugin in this case from plugins list

piotrbak commented 1 year ago

@CrochetFeve0251 Aren't we checking the AS tables when installing/updating the WP Rocket? 🤔