From a962060e730fbbf21313b4e9969cf910ae891446 Mon Sep 17 00:00:00 2001 From: ella Date: Sat, 25 Oct 2025 09:50:02 +0200 Subject: [PATCH 1/2] Template activation: add migration --- src/wp-admin/includes/upgrade.php | 44 +++++++++++++++++++++++++++++++ src/wp-includes/version.php | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index c8235c314f431..1940b3c1dec83 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -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, + '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. * diff --git a/src/wp-includes/version.php b/src/wp-includes/version.php index d897a077b226b..dc25764035989 100644 --- a/src/wp-includes/version.php +++ b/src/wp-includes/version.php @@ -23,7 +23,7 @@ * * @global int $wp_db_version */ -$wp_db_version = 60717; +$wp_db_version = 60718; /** * Holds the TinyMCE version. From aac42d730c80c426728138f96407225266656be3 Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Mon, 27 Oct 2025 10:37:46 +0100 Subject: [PATCH 2/2] Update src/wp-admin/includes/upgrade.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/upgrade.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 1940b3c1dec83..c2270aa8196d7 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -2497,8 +2497,10 @@ 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`. + /* + * 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',