Make WordPress Core

Changeset 51595


Ignore:
Timestamp:
08/10/2021 05:55:37 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Editor: Preserve the original template keys when preparing a list of page templates.

Previously, the original "404" template key was lost when "Default template" is merged into the available templates array, as the array_merge() function renumbers numeric keys. Later, when we merge templates on the client side, this caused duplicate "404" templates to appear in the dropdown.

By replacing the array_merge() call with array_replace(), we make sure to keep the original numeric keys.

Props Mamaduka, Toro_Unit, youknowriad.
Fixes #53898.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r51200 r51595  
    120120 */
    121121$available_templates = wp_get_theme()->get_page_templates( get_post( $post->ID ) );
    122 $available_templates = ! empty( $available_templates ) ? array_merge(
     122$available_templates = ! empty( $available_templates ) ? array_replace(
    123123    array(
    124124        /** This filter is documented in wp-admin/includes/meta-boxes.php */
Note: See TracChangeset for help on using the changeset viewer.