-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Template activation: update migration #10418
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
base: trunk
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -886,6 +886,10 @@ function upgrade_all() { | |
| upgrade_682(); | ||
| } | ||
|
|
||
| if ( $wp_current_db_version < 60718 ) { | ||
| upgrade_690(); | ||
| } | ||
|
|
||
| maybe_disable_link_manager(); | ||
|
|
||
| maybe_disable_automattic_widgets(); | ||
|
|
@@ -2481,6 +2485,46 @@ function ( $url ) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Executes changes made in WordPress 6.9.0. | ||
| * | ||
| * @ignore | ||
| * @since 6.9.0 | ||
| * | ||
| * @global int $wp_current_db_version The old (current) database version. | ||
| */ | ||
| function upgrade_690() { | ||
| global $wp_current_db_version; | ||
|
|
||
| if ( $wp_current_db_version < 60718 ) { | ||
| // Query all templates in the database that are linked to the current | ||
| // theme and activate them. See `get_block_templates`. | ||
| $template_query_args = array( | ||
| 'post_status' => 'publish', | ||
| 'post_type' => 'wp_template', | ||
| 'posts_per_page' => -1, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that this is a direct copy from I think that we should revisit I'm not sure what the most performant option is without testing, but here are a possible ideas:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw I don’t think we do cron because that risks there to be missing templates on the front end during this time.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can't assume that upgrade routines are run, in the case of Multisite they're often not run until months after the update (IMHO - because it requires a manual action in wp-admin/network from a super-admin) and in the case of automatic updates the routines should be run but sometimes are not until a user accesses wp-admin/ and goes through the If WordPress requires this before
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW I'm not overly concerned about the unbounded query here,
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @desrosj @dd32 @mcsf Any strong opinion on not running the migration on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No real preference here between hooking to Where I do have a preference is to avoid migrating on But note that, regardless of choosing
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also have a preference to avoid I think I prefer @dd32's suggestion because of the added protection against a potential flood of requests. If a site is hit by 1,000s of requests before the first one can complete, each of those would perform an
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason I don't like it on It also relies upon the reader to see the In many respects, it seems that the option is being used here as a cache layer too? In other words; this shouldn't be an option at all, and rather should be a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dd32 No, |
||
| 'no_found_rows' => true, | ||
| 'lazy_load_term_meta' => false, | ||
| 'tax_query' => array( | ||
| array( | ||
| 'taxonomy' => 'wp_theme', | ||
| 'field' => 'name', | ||
| 'terms' => get_stylesheet(), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| $template_query = new WP_Query( $template_query_args ); | ||
| $active_templates = array(); | ||
|
|
||
| foreach ( $template_query->posts as $post ) { | ||
| $active_templates[ $post->post_name ] = $post->ID; | ||
| } | ||
|
|
||
| update_option( 'active_templates', $active_templates ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Executes network-level upgrade routines. | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.