gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Error with navigation-link.php

Open lwangdu opened this issue 5 years ago • 4 comments

Description

I am getting the following error in the front end. Notice: Trying to get property 'post_status' of non-object in /Users/lwangdu/Sites/fullsiteediting/wp-content/plugins/gutenberg/build/block-library/blocks/navigation-link.php on line 133

Step-by-step reproduction instructions

Create new post. Permalink section > click on view post.

Screenshots, screen recording, code snippet

Screen Shot 2021-09-16 at 7 40 12 AM

Environment info

WordPress 5.8.1, Gutenberg version 11.5.0 Theme TT1 Blocks Browser: Chrome MAC OS Version 11.6

Please confirm that you have searched existing issues in the repo.

No

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

lwangdu avatar Sep 16 '21 14:09 lwangdu

I believe this happens when the navigation block has links to posts or pages that does not exist on the site we are currently on.

This can be reproduce by adding a navigation link with a random ID that does not exist on the current website:

<!-- wp:navigation -->
<!-- wp:navigation-link {"label":"Test","type":"page","id":11111111,"url":"http://localhost:8888/test/","kind":"post-type","isTopLevelLink":true} /-->
<!-- /wp:navigation -->

carolinan avatar Sep 21 '21 04:09 carolinan

Thanks for that. I just out that myself. I tried another block theme and I didn't get the error. I switch back back to TT1 and I didn't navigation links and error was gone.

lwangdu avatar Sep 21 '21 13:09 lwangdu

That makes sense, if the problem is in a template that is unique to the theme.

In TT1-blocks, the default header template has an empty menu. <!-- wp:navigation {"orientation":"horizontal","itemsJustification":"right"} /--> I am not able to reproduce the PHP notice with this menu.

Did you make changes to the navigation block? I mean in the options.

carolinan avatar Sep 22 '21 03:09 carolinan

No I didn't thinking I made changes on the navigation block. I tried again it seems work right now. Thank you.

lwangdu avatar Sep 22 '21 15:09 lwangdu