wp-media / wp-rocket

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

Detect Action Scheduler tables integrity, for example "autoincrement" for id columns #5489

Closed alfonso100 closed 2 months ago

alfonso100 commented 1 year ago

Before submitting an issue please check that you’ve completed the following steps: yes - Made sure you’re on the latest version yes - Used the search feature to ensure that the bug hasn’t been reported before

Describe the bug If AS tables don't have the autoincrement value in the respective id fields, it will trigger errors when trying to activate WP Rocket.

Fatal error: Uncaught RuntimeException: Error saving action: Error saving action: Database error. in /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/ActionScheduler/classes/migration/ActionScheduler_DBStoreMigrator.php:44 Stack trace: #0 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_HybridStore.php(242): ActionScheduler_DBStoreMigrator->save_action(Object(ActionScheduler_Action), NULL) #1 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/ActionScheduler/classes/ActionScheduler_ActionFactory.php(177): ActionScheduler_HybridStore->save_action(Object(ActionScheduler_Action)) #2 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/ActionScheduler/classes/ActionScheduler_ActionFactory.php(69): ActionScheduler_ActionFactory->store(Object(ActionScheduler_Action)) #3 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/ActionScheduler/functions.php(19): ActionScheduler_ActionFactory->async('rocket_preload_...', Array, 'rocket-preload') #4 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Engine/Common/Queue/AbstractASQueue.php(25): as_enqueue_async_action('rocket_preload_...', Array, 'rocket-preload') #5 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Engine/Preload/Controller/Queue.php(24): WP_Rocket\Engine\Common\Queue\AbstractASQueue->add_async('rocket_preload_...') #6 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Engine/Preload/Activation/Activation.php(45): WP_Rocket\Engine\Preload\Controller\Queue->add_job_preload_job_load_initial_sitemap_async() #7 [internal function]: WP_Rocket\Engine\Preload\Activation\Activation->activate() #8 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Inflector/Inflector.php(116): call_user_func_array(Array, Array) #9 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Inflector/InflectorAggregate.php(53): WP_Rocket\Dependencies\League\Container\Inflector\Inflector->inflect(Object(WP_Rocket\Engine\Preload\Activation\Activation)) #10 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Container.php(158): WP_Rocket\Dependencies\League\Container\Inflector\InflectorAggregate->inflect(Object(WP_Rocket\Engine\Preload\Activation\Activation)) #11 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Engine/Preload/Activation/ServiceProvider.php(57): WP_Rocket\Dependencies\League\Container\Container->get('preload_activat...') #12 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/ServiceProvider/ServiceProviderAggregate.php(102): WP_Rocket\Engine\Preload\Activation\ServiceProvider->register() #13 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Container.php(172): WP_Rocket\Dependencies\League\Container\ServiceProvider\ServiceProviderAggregate->register('preload_activat...') #14 /home/public_html/example/wp-content/plugins/wp-rocket/inc/Engine/Activation/Activation.php(47): WP_Rocket\Dependencies\League\Container\Container->get('preload_activat...') #15 /home/public_html/example/wp-includes/class-wp-hook.php(307): WP_Rocket\Engine\Activation\Activation::activate_plugin('') #16 /home/public_html/example/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array) #17 /home/public_html/example/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #18 /home/public_html/example/wp-admin/plugins.php(194): do_action('activate_wp-roc...') #19 {main} thrown in /home/public_html/example/wp-content/plugins/wp-rocket/inc/Dependencies/ActionScheduler/classes/migration/ActionScheduler_DBStoreMigrator.php on line 44

To Reproduce Steps to reproduce the behavior:

  1. Remove autoincrement from AS tables
  2. Enable WP Rocket
  3. See errors

Expected behavior On activation, we could check the integrity of the tables and fix it if possible. Autoincrement is an obvious one, but maybe there are more things we can detect

Screenshots This happened in one case with the AS groups table: 2022-09-30_17-54

Additional context ticket: https://secure.helpscout.net/conversation/2022850427/371623?folderId=2683093

Backlog Grooming (for WP Media dev team use only)

piotrbak commented 1 year ago

@wp-media/php What do you think about this one?

engahmeds3ed commented 1 year ago

This isn't a common case and isn't related directly to WP Rocket, I'd say we can create GH issue in Action Scheduler's repository and we can discuss there to see what is the root cause behind such thing. What do u think?

piotrbak commented 1 year ago

@engahmeds3ed Yes, that sounds good. We'll keep this issue open to collect cases though.

piotrbak commented 2 months ago

We did not have any feedback from customers about this issue.