Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#53898 closed defect (bug) (fixed)

Duplicated 404 templates in the TemplatePanel

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

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 5 years ago.

Download all attachments as: .zip

Change History (15)

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


5 years ago
#1

  • 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
5 years ago

The issue was reported by @toro_unit.

Mamaduka commented on PR #1561:


5 years ago
#3

/cc @gziolo

Mamaduka commented on PR #1561:


5 years ago
#4

/cc @gziolo

gziolo commented on PR #1561:


5 years ago
#5

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

Mamaduka commented on PR #1561:


5 years ago
#6

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

#7 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review5.8.1

Mamaduka commented on PR #1561:


5 years ago
#8

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
5 years ago

Thanks for the review, @SergeyBiryukov.

#10 @youknowriad
5 years ago

  • Keywords commit added

#11 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

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
5 years ago

  • Keywords fixed-major added
  • Resolution fixed
  • Status closedreopened

Reopening for backporting to the 5.8 branch.

#14 @desrosj
5 years ago

  • Resolutionfixed
  • Status reopenedclosed

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.