WordPress.org

Make WordPress Core

Opened 6 weeks ago

Closed 5 weeks ago

#53898 closed defect (bug) (fixed)

Duplicated 404 templates in the TemplatePanel

Reported by: Mamaduka Owned by: SergeyBiryukov
Milestone: 5.8.1 Priority: normal
Severity: normal Version: 5.8
Component: Editor Keywords: has-patch commit fixed-major
Focuses: Cc:

Description

The issue was initially reported on Github - https://github.com/WordPress/gutenberg/issues/33929.

The original "404" template key is lost when we merge "Default template" into the available templates array. The array_merge will re-index/re-number keys with numbering values.

Later, when we merge templates on the client-side, this causes duplicated "404" templates in the dropdown.

Attachments (1)

CleanShot 2021-08-09 at 10.50.04.png (38.7 KB) - added by Mamaduka 6 weeks ago.

Download all attachments as: .zip

Change History (15)

This ticket was mentioned in PR #1561 on WordPress/wordpress-develop by Mamaduka.


6 weeks ago

  • Keywords has-patch added

Changes array_merge with array_replace. The latter will keep the same numeric keys.

Verification example: https://3v4l.org/tlft6

Trac ticket: https://core.trac.wordpress.org/ticket/53898

#2 @Mamaduka
6 weeks ago

The issue was reported by @toro_unit.

#3 @prbot
6 weeks ago

Mamaduka commented on PR #1561:

/cc @gziolo

#4 @prbot
6 weeks ago

Mamaduka commented on PR #1561:

/cc @gziolo

#5 @prbot
6 weeks ago

gziolo commented on PR #1561:

I don't know this functionalit. @youknowriad, can you help with the review?

#6 @prbot
6 weeks ago

Mamaduka commented on PR #1561:

@gziolo apologies. I pinged you since this was editor settings related.

#7 @SergeyBiryukov
6 weeks ago

  • Milestone changed from Awaiting Review to 5.8.1

#8 @prbot
6 weeks ago

Mamaduka commented on PR #1561:

Thanks for the review, @youknowriad.

I think I need to swap argument positions so the "Default template" is always the first item in the array.

I will push this change in few minutes.

#9 @Mamaduka
6 weeks ago

Thanks for the review, @SergeyBiryukov.

#10 @youknowriad
6 weeks ago

  • Keywords commit added

#11 @SergeyBiryukov
6 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 51595:

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.

#12 @SergeyBiryukov
6 weeks ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backporting to the 5.8 branch.

#14 @desrosj
5 weeks ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 51620:

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, SergeyBiryukov.
Merges [51595] to the 5.8 branch.
Fixes #53898.

Note: See TracTickets for help on using tickets.