[wp-trac] [WordPress Trac] #37026: PHP Notice: Trying to get property of non-object in wp-admin\nav-menus.php on line 836
WordPress Trac
noreply at wordpress.org
Sun Jun 1 20:00:17 UTC 2025
#37026: PHP Notice: Trying to get property of non-object in wp-admin\nav-menus.php
on line 836
-------------------------------------------------+-------------------------
Reporter: skylarkcob | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.9
Component: Menus | Version: 3.0
Severity: normal | Resolution:
Keywords: has-patch needs-copy-review | Focuses:
changes-requested |
-------------------------------------------------+-------------------------
Changes (by SirLouen):
* keywords: has-patch => has-patch needs-copy-review changes-requested
Comment:
== Combined Bug Reproduction and Patch Testing Report
=== Description
🟠 This report validates that the indicated patch works but with some
caveats
Patch tested: REPLACE_WITH_PATCH_URL
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 137.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-One 2.5
- MU Plugins: None activated
- Plugins:
* Test Reports 1.2.0
=== Testing Instructions
I cannot really reproduce this through regular, only reproducible under
certain forced conditions where regular menus are not being used (as the
scenario commented by the OP). The only solution comes to adding a code to
a plugin, to forcefully set an unexistent menu to an existing location.
1. Add the following code to a plugin:
{{{
$locations = get_nav_menu_locations();
$locations['primary'] = 12345;
set_theme_mod('nav_menu_locations', $locations);
}}}
2. 🐞 Error condition reproduced
=== Actual Results
1. 🟠 Issue resolved with patch with concerns
=== Additional Notes
- I have one main concern. With the patch, the fact is that the location
is still assigned to an inexistent menu and nothing is informing of such.
I feel that this patch is just hiding the error, but not dealing with it.
In fact, the error is posing something that is intrinsically wrong. You
can deal with the error by simply going into Menu > Manage Locations > And
assigning the right Menu to the conflicting location.
- My suggestion would be to add a notice explaining what is going on with
this error. Something like
"Your $menu_locations[ $location ] location has a wrong menu assigned.
Please, assign a valid menu"
- I'm assuming that my error is a little different because it has been 9
years after the report was done.
=== Supplemental Artifacts
Error condition
[[Image(https://i.imgur.com/WGc42Q3.png)]]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37026#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list