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

Update table install process #245

Merged
merged 5 commits into from
Jan 19, 2022
Merged

Conversation

WPprodigy
Copy link
Contributor

@WPprodigy WPprodigy commented Jan 17, 2022

  • Helps resolve an issue noted in Task: Cleanup database installation process #232 where a site has the option set but doesn't actually have the table installed. So instead the is_installed() check now directly checks if the table exists and use the site cache instead of relying just on the option.
  • wpmu_new_blog is deprecated, so swapping it out for wp_insert_site.
  • Removes some of the direct side-effects from file-loading, and instead more decisively bootstraps the plugin.

Also simplified the usage a bit, now just have the public methods listed below. I checked the methods I removed and didn't see any usage, but because they were public I've added them back with deprecation notices just for extra safety during updates.

is_installed()
install()
maybe_install_during_shutdown()
drop_tables_on_subsite_removal()

The only piece this PR doesn't solve for is the "Prepare for schema changes" action item. Will handle that separately when the time comes, probably with needs_db_update() and maybe_run_database_update() methods.

Testing

Single Site:

  1. Setup a fresh single site and check that the table is created.
  2. Delete the table manually and flush cache. Reload and see if table is created.

Multisite:

  1. Setup a fresh multisite and check that the table is created on the root site.
  2. Create a new subsite and check the the table is created.
  3. Delete the table on the root site and subsite, flush cache on both. Reload and ensure table was added back.
includes/wp-adapter.php Outdated Show resolved Hide resolved
@WPprodigy WPprodigy marked this pull request as draft January 17, 2022 01:46
@WPprodigy WPprodigy marked this pull request as ready for review January 19, 2022 04:00
@WPprodigy
Copy link
Contributor Author

WPprodigy commented Jan 19, 2022

Did some pretty extensive testing, all looks good.

I like that the install process is rather deterministic. Before it's had the chance to install the custom table, it will carry on and use the the core cron option per a default wp installation. It will install the table on either the installation request (for new subsites for example) or on shutdown of an admin/cli/cron request - but it carries on using the cron option per usual for the whole request if the table wasn't installed yet. Only on the next request does it start using the new tables and our custom functionality - so there is never a scenario where it'll half use cron option and half use the custom table.

@WPprodigy WPprodigy merged commit 5621149 into master Jan 19, 2022
@WPprodigy WPprodigy deleted the update/database-table-installation branch January 19, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants