From 08f5675e1c134da220b275bce696718c9a2b12c4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 23 Aug 2022 14:52:12 +0000 Subject: [PATCH] Editor: Ensure `get_block_templates()` returns unique templates or template parts. The function was using the `array_column()` PHP function on an array of objects, which works as expected on PHP 7 or later, but not on PHP 5.6. This resulted in customized templates being listed multiple times on the Templates and Template Parts screens, and being repeatedly added between lists when switching between the screens. The issue is now resolved by replacing `array_column()` with the `wp_list_pluck()` WordPress core function, which provides consistent behavior beetween PHP versions. Reference: [https://github.com/php/php-src/blob/PHP-7.0.0/UPGRADING#L626 PHP 7.0 Upgrade Notes: array_column()]. Props uofaberdeendarren, antonvlasenko, ironprogrammer, jonmackintosh, costdev, hellofromTonya, swissspidy, rudlinkon. Fixes #56271. Built from https://develop.svn.wordpress.org/trunk@53927 git-svn-id: http://core.svn.wordpress.org/trunk@53486 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-template-utils.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/block-template-utils.php b/wp-includes/block-template-utils.php index 951bd523c2..08933d4f81 100644 --- a/wp-includes/block-template-utils.php +++ b/wp-includes/block-template-utils.php @@ -696,7 +696,7 @@ function get_block_templates( $query = array(), $template_type = 'wp_template' ) $is_not_custom = false === array_search( wp_get_theme()->get_stylesheet() . '//' . $template_file['slug'], - array_column( $query_result, 'id' ), + wp_list_pluck( $query_result, 'id' ), true ); $fits_slug_query = diff --git a/wp-includes/version.php b/wp-includes/version.php index 9eadffc8ed..be0d6d1684 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53924'; +$wp_version = '6.1-alpha-53927'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.