Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionScheduler tables are not reinitialized after manually deleting the tables #1032

Open
HamzaDincer opened this issue Feb 22, 2024 · 3 comments
Labels
priority: normal The issue/PR is normal priority—not many people are affected or there’s a workaround, etc. type: enhancement The issue is a request for an enhancement.

Comments

@HamzaDincer
Copy link

I am trying to integrate the action scheduler lib into my plugin. I wanted to test whether it will generate the tables again after I deleted them (manually on phpadmin) and it did not. My env is running in docker container together with phpadmin, mysql, wp. I solved the problem by restarting my env from the scratch. I am worrying it may cause problem for plugin in the future if a client deleted the tables accidentially and it will not generate the tables again for them.

[php:notice] [pid 19] [client 192.168.65.1:64193] WordPress database error Table 'wordpress.wp_actionscheduler_groups' doesn't exist for query SELECT group_id FROM wp_actionscheduler_groups WHERE slug='' made by require_once('wp-admin/admin.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, test_action_scheduler, as_enqueue_async_action, ActionScheduler_ActionFactory->create, ActionScheduler_ActionFactory->store, ActionScheduler_HybridStore->save_action, ActionScheduler_DBStoreMigrator->save_action, ActionScheduler_DBStore->save_action, ActionScheduler_DBStore->save_action_to_db, ActionScheduler_DBStore->get_group_ids, referer: http://localhost:8000/wp-admin/plugins.php?plugin_status=all&paged=1&s

@Konamiman Konamiman added the type: enhancement The issue is a request for an enhancement. label Feb 23, 2024
@Konamiman
Copy link
Contributor

Hi, that makes sense and I'm labeling this as an enhancement request, thanks. However I'd like to point out that there's another way to force te regeneration of the tables without having to do a full restart of your environment: just go to WordPress' Tools - Scheduled Actions menu, and if the tables have been deleted, they'll be created again and you'll see the following notice:

image

@HamzaDincer
Copy link
Author

Thanks for the solution and help. It worked but it still does not create tables without going to WordPress' Tools - Scheduled Actions menu. I think it would be better for the library to create the tables during the activation of the plugin for users. If I find a time, I will try to find why it does not create the missing tables during activation, maybe post a pr.

@lsinger
Copy link
Contributor

lsinger commented Mar 1, 2024

I think it would be better for the library to create the tables during the activation of the plugin for users

The schema_update_required checks for the presence of an option to determine whether the schema has been created at one point (if ( 0 === $this->db_version ) { ...). If you delete the tables but not that option, Action Scheduler won't re-attempt creating the tables.

We do agree though that the fact that the tables are missing should be more discoverable, and maybe we should try re-creating them. It would be important for a solution here to keep in mind that they might be missing because of a problem with the database (permissions, etc.) so we shouldn't try creating them on every request. We could again use an option to store when we last attempted recreating them and implement some sort of back-off function that leaves more and more time between unsuccessful attempts.

@lsinger lsinger added the priority: normal The issue/PR is normal priority—not many people are affected or there’s a workaround, etc. label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: normal The issue/PR is normal priority—not many people are affected or there’s a workaround, etc. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

No branches or pull requests

3 participants