Make WordPress Core

Opened 4 days ago

Last modified 39 hours ago

#65287 assigned defect (bug)

block_core_navigation_submenu_render_submenu_icon() removed without deprecation, causing fatal errors on sites using the function

Reported by: ecairol's profile ecairol Owned by: ecairol's profile ecairol
Milestone: 7.0.1 Priority: normal
Severity: normal Version: 7.0
Component: Editor Keywords: has-patch has-unit-tests close
Focuses: Cc:

Description (last modified by sabernhardt)

Version: Gutenberg 23.x / WP 7.0

Description

block_core_navigation_submenu_render_submenu_icon() was silently removed in
Gutenberg PR #74853 (synced to Core via wordpress-develop PR #10865 in [61605])
as part of a refactor that consolidated submenu icon rendering into a new shared
function: block_core_shared_navigation_render_submenu_icon().

The old was deleted with no
_deprecated_function(). Since no backwards-compatible alias
was provided, this is a breaking change for any theme or plugin that
previously called the function directly.

Steps to Reproduce

  1. Install or activate a custom theme (or plugin) that calls block_core_navigation_submenu_render_submenu_icon() as part of a render_block_core/navigation-submenu filter (a documented and reasonable usage pattern for customizing the dropdown chevron icon).
  2. Update to Gutenberg 23.x (or WordPress 7.0 with the synced change).
  3. Load any page on the site.

Expected Behavior

  • The function call either continues to work, OR
  • WordPress triggers a _deprecated_function() notice with guidance to use block_core_shared_navigation_render_submenu_icon() instead, while remaining functional until a future major version.

Actual Behavior

A fatal PHP error is thrown.

Proposed Fix

Add a deprecated shim in Core.

In wp-includes/blocks/navigation-submenu.php (or wherever the function
previously lived), add a backwards-compatible wrapper:

<?php
/**
 * Renders the submenu icon SVG for the Navigation Submenu block.
 *
 * @deprecated Use block_core_shared_navigation_render_submenu_icon() instead.
 * @return string SVG markup for the submenu icon.
 */
function block_core_navigation_submenu_render_submenu_icon() {
    _deprecated_function(
        __FUNCTION__,
        '7.0.0',
        'block_core_shared_navigation_render_submenu_icon()'
    );
    return block_core_shared_navigation_render_submenu_icon();
}

References
Gutenberg PR (introduced change): https://github.com/WordPress/gutenberg/pull/74853
WP Core sync PR: https://github.com/WordPress/wordpress-develop/pull/10865

Attachments (1)

trac-65287.diff (1.9 KB) - added by ecairol 4 days ago.

Download all attachments as: .zip

Change History (11)

#1 @ramonopoly
4 days ago

Thanks for the ticket @ecairol It looks like it should not have been deprecated. It's been around since 5.9:

https://github.com/WordPress/wordpress-develop/blob/5.9/src/wp-includes/blocks/navigation-submenu.php#L112

Last edited 4 days ago by ramonopoly (previous) (diff)

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


4 days ago
#2

  • Keywords has-unit-tests added

## Summary

block_core_navigation_submenu_render_submenu_icon() was removed from src/wp-includes/blocks/navigation-submenu.php in 60810 (Gutenberg PR #74853, synced via wordpress-develop PR #10865) as part of consolidating submenu icon rendering into the new shared helper block_core_shared_navigation_render_submenu_icon().

The removal landed without a _deprecated_function() notice or a backwards-compatible shim, so any theme or plugin that previously called the function — for example from a render_block_core/navigation-submenu filter to customise the dropdown chevron — now triggers a fatal PHP error on 7.0.

This PR restores the function as a thin deprecation shim:

  • Triggers _deprecated_function() so callers see actionable guidance to migrate to block_core_shared_navigation_render_submenu_icon().
  • Returns the output of the new helper, preserving the original rendered markup.
  • Includes a phpunit test asserting the deprecation notice fires and the return value matches the new helper.

## Test plan

  • [ ] php -l src/wp-includes/blocks/navigation-submenu.php passes (verified locally).
  • [ ] phpunit --filter Tests_Blocks_NavigationSubmenuRenderSubmenuIcon passes.
  • [ ] On a site whose theme calls block_core_navigation_submenu_render_submenu_icon(), the page renders without a fatal and a deprecation notice is logged.
  • [ ] Existing Navigation Submenu rendering is unchanged (the shim is only used by external callers).

Props ecairol.

#3 @sabernhardt
4 days ago

  • Component changed from Menus to Editor
  • Description modified (diff)
  • Milestone changed from Awaiting Review to 7.0.1

@ecairol
4 days ago

#4 @ecairol
4 days ago

PR opened: https://github.com/WordPress/wordpress-develop/pull/11914
UPDATE: This was closed, wrong repo.

Last edited 4 days ago by ecairol (previous) (diff)

@ecairol commented on PR #11914:


4 days ago
#5

Closing — wrong repo for this fix.

CI surfaced the actual situation: src/wp-includes/blocks/navigation-submenu.php is now overlaid by the gutenberg:copy build step from the Gutenberg release, so a wordpress-develop-only change to that file fails git diff --exit-code. The canonical fix has to land in WordPress/gutenberg first and propagate via the Gutenberg → Core sync.

Re-opening as a Gutenberg PR against packages/block-library/src/navigation-submenu/index.php. Will link the new PR back to Trac #65287.

@ramonopoly commented on PR #11914:


4 days ago
#7

Re-opening as a Gutenberg PR against packages/block-library/src/navigation-submenu/index.php. Will link the new PR back to Trac #65287.

Good call. I guess the deprecation wrapper can be packages/block-library/src/navigation-link/shared/render-submenu-icon.php. Same fix as here.

Thank you for handling this!

@ramonopoly commented on PR #11914:


4 days ago
#8

I guess the deprecation wrapper can be packages/block-library/src/navigation-link/shared/render-submenu-icon.php.

I withdraw that. What you've done in https://github.com/WordPress/gutenberg/pull/78484 LGTM. Thanks again

#9 @westonruter
3 days ago

  • Owner set to ecairol
  • Status changed from new to assigned

#10 @wildworks
39 hours ago

  • Keywords close added

Since https://github.com/WordPress/gutenberg/pull/78484 has been merged, I recommend closing this ticket.

Note: See TracTickets for help on using tickets.