diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index c8235c314f431..c2270aa8196d7 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,48 @@ 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.