ClassicPress/ClassicPress-v2

Undefined property: stdClass:: ... in .../wp-includes/class-walker-nav-menu.php🐞

Closed this issue · 5 comments

Expected behavior

Pages should load without errors occurring.

Current behavior

Loading an uncached menu can generate the following errors:

Undefined property: stdClass::$target in ../wp-includes/class-walker-nav-menu.php on line 180
Undefined property: stdClass::$xfn in ../wp-includes/class-walker-nav-menu.php on line 183
Undefined property: stdclass::$current in ../wp-includes/class-walker-nav-menu.php on line 196

Reported on WP Trac at https://core.trac.wordpress.org/ticket/46382

Possible solution

I have provided the solution on the above Trac ticket at https://core.trac.wordpress.org/ticket/46382#comment:5

Steps to reproduce bug

Load a page. This must be uncached, and so must the menu. (Some themes and plugins cache either or both, so these errors don't appear for everyone.)

Context

No response

ClassicPress version

2.0

PHP version

8.1

Can you help?

I can help test a solution

@mattyrob is this something we can implement ourselves or wait on WP to fix to backport?

@viktorix - it’s been sitting for 4 years at WP. I’ll see what I can do.

I'm finding it hard to get these errors to show for me locally but I can see the potential for the issue in the code. I've created a branch that should address this if someone can test it please:

https://github.com/ClassicPress/ClassicPress-v2/tree/fix/nav-menu-notices

KTS915 commented

Yes, it's hard to know the precise conditions necessary to cause the problem, but your fix is working for me.

Fixed in #145