Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#53898 closed defect (bug) (fixed)

Duplicated 404 templates in the TemplatePanel

Reported by: mamaduka's profile Mamaduka Owned by: sergeybiryukov's profile 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 3 years ago.

Download all attachments as: .zip

Change History (15)

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


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

The issue was reported by @toro_unit.

Mamaduka commented on PR #1561:


3 years ago
#3

/cc @gziolo

Mamaduka commented on PR #1561:


3 years ago
#4

/cc @gziolo

gziolo commented on PR #1561:


3 years ago
#5

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

Mamaduka commented on PR #1561:


3 years ago
#6

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

#7 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 5.8.1

Mamaduka commented on PR #1561:


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

Thanks for the review, @SergeyBiryukov.

#10 @youknowriad
3 years ago

  • Keywords commit added

#11 @SergeyBiryukov
3 years 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
3 years ago

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

Reopening for backporting to the 5.8 branch.

#14 @desrosj
3 years 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.