Make WordPress Core

Changeset 62926


Ignore:
Timestamp:
07/29/2026 06:54:20 PM (4 months ago)
Author:
westonruter
Message:

Menus: Pass the missing $menu_data to the wp_update_nav_menu action.

The action has documented a $menu_data parameter since 3.0.0, when it was introduced in wp_update_nav_menu_object(). However, this parameter was not passed to all instances of the action being fired, resulting in a possible fatal error if a callback is expecting it.

Neither of these call sites has menu data to supply: wp_nav_menu_update_menu_items() fires the action after updating a menu's items, and WP_REST_Menus_Controller::handle_auto_add() after updating the nav_menu_options option. Both now pass an empty array to satisfy the documented signature.

These call sites were surfaced by the PHPStan extensions under development for this ticket, which are committed separately.

Developed as subset of ​https://github.com/WordPress/wordpress-develop/pull/12022.
Follow-up to r15104, r23441, r52079.

See #65376, #40878.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/nav-menu.php

    r62097 r62926  
    15101510
    15111511        /** This action is documented in wp-includes/nav-menu.php */
    1512         do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
     1512        do_action( 'wp_update_nav_menu', $nav_menu_selected_id, array() );
    15131513
    15141514        /* translators: %s: Nav menu title. */
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php

    r59718 r62926  
    454454
    455455                /** This action is documented in wp-includes/nav-menu.php */
    456                 do_action( 'wp_update_nav_menu', $menu_id );
     456                do_action( 'wp_update_nav_menu', $menu_id, array() );
    457457
    458458                return $update;
Note: See TracChangeset for help on using the changeset viewer.