Make WordPress Core

Opened 6 weeks ago

Closed 2 weeks ago

#64072 closed defect (bug) (fixed)

Improve error message in `WP_Block_Templates_Registry::unregister()` to include template name

Reported by: mukesh27's profile mukesh27 Owned by: mukesh27's profile mukesh27
Milestone: 6.9 Priority: normal
Severity: normal Version: 6.7
Component: Editor Keywords: has-patch has-unit-tests
Focuses: template Cc:

Description

Currently, when attempting to unregister a non-existent block template, WP_Block_Templates_Registry::unregister() returns a generic error message without reference to the template name. It use __( 'Template "%s" is not registered.' ) in error message without using template name.

Change History (2)

This ticket was mentioned in PR #10134 on WordPress/wordpress-develop by @mukesh27.


6 weeks ago
#1

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

  • Updated the unregister method in WP_Block_Templates_Registry to ensure that the error message returned when trying to unregister a non-registered template includes the template name, making debugging easier.
  • Added a new PHPUnit test to verify that unregister_block_template() returns a WP_Error containing the template name when attempting to unregister a template that is not registered. This test also checks for the correct usage notice.

#2 @SergeyBiryukov
2 weeks ago

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

In 61090:

Editor: Correct error message in WP_Block_Templates_Registry::unregister().

When attempting to unregister a non-existent block template, the error message will now include the template name.

Follow-up to [59073].

Props mukesh27, shailu25.
Fixes #64072.

Note: See TracTickets for help on using tickets.