Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Error: Attempt to assign property "parsed_block" on null #46294

Closed
bph opened this issue Dec 4, 2022 · 10 comments
Closed

Fatal Error: Attempt to assign property "parsed_block" on null #46294

bph opened this issue Dec 4, 2022 · 10 comments
Labels
[Block] Navigation Affects the Navigation Block [Type] Bug An existing feature does not function as intended

Comments

@bph
Copy link
Contributor

bph commented Dec 4, 2022

Description

  • Seems the error was introduced after 4.7.0 RC 1 was compiled (Nov 30)

Full error message + stack

[04-Dec-2022 09:00:53 UTC] PHP Fatal error: Uncaught Error: Attempt to assign property "parsed_block" on null in /wp-includes/class-wp-block.php:239
Stack trace:
#0 /wp-content/plugins/gutenberg/build/block-library/blocks/navigation.php(707): WP_Block->render()
#1 /wp-includes/class-wp-block.php(258): gutenberg_render_block_core_navigation()
#2 /wp-includes/class-wp-block.php(244): WP_Block->render()
#3 /wp-includes/class-wp-block.php(244): WP_Block->render()
#4 /wp-includes/blocks.php(1051): WP_Block->render()
#5 /wp-includes/blocks.php(1089): render_block()
#6 /wp-content/plugins/gutenberg/build/block-library/blocks/template-part.php(131): do_blocks()
#7 /wp-includes/class-wp-block.php(258): gutenberg_render_block_core_template_part()
#8 /wp-includes/blocks.php(1051): WP_Block->render()
#9 /wp-includes/blocks.php(1089): render_block()
#10 /wp-includes/block-template.php(240): do_blocks()
#11 /wp-includes/template-canvas.php(12): get_the_block_template_html()
#12 /wp-includes/template-loader.php(106): include('...')
#13 /wp-blog-header.php(19): require_once('...')
#14 /index.php(17): require('...')
#15 {main}
thrown in /wp-includes/class-wp-block.php on line 239

Step-by-step reproduction instructions

Still trying to figure out what exactly goes wrong.

What I tried

  • Using GB 14.6.1 no error message
  • Using 14.7.0 RC 1 no error message.
  • Using WP 6.1.1 + Gutenberg Nightly = error message

Environment info

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

Yes

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

Yes

Header Core containing the navigation


<!-- wp:group {"className":"gapless-group","layout":{"inherit":"true","type":"constrained"}} -->
  <div class="wp-block-group gapless-group"><!-- wp:group {"align":"full","style":{"spacing":{"padding":{"bottom":"var(\u002d\u002dwp\u002d\u002dcustom\u002d\u002dgap\u002d\u002dvertical)","top":"var(\u002d\u002dwp\u002d\u002dcustom\u002d\u002dgap\u002d\u002dvertical)"}}},"className":"site-header site-header-linear","layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"center"}} -->
  <div class="wp-block-group alignfull site-header site-header-linear" style="padding-top:var(--wp--custom--gap--vertical);padding-bottom:var(--wp--custom--gap--vertical)"><!-- wp:group {"className":"site-brand","layout":{"type":"flex"}} -->
  <div class="wp-block-group site-brand"><!-- wp:site-logo {"width":64} /-->
  
  <!-- wp:group {"className":"site-words-stack-small","layout":{"type":"constrained","justifyContent":"left"}} -->
  <div class="wp-block-group site-words-stack-small"><!-- wp:site-title {"style":{"typography":{"textTransform":"capitalize"}}} /-->
  
  <!-- wp:site-tagline {"style":{"typography":{"fontSize":"var(\u002d\u002dwp\u002d\u002dcustom\u002d\u002dfont-sizes\u002d\u002dx-small)"}}} /--></div>
  <!-- /wp:group --></div>
  <!-- /wp:group -->
  
  <!-- wp:navigation {"ref":740,"__unstableLocation":"primary","className":"blockbase-responsive-navigation-linear","layout":{"type":"flex","setCascadingProperties":true,"justifyContent":"right","orientation":"horizontal"},"style":{"spacing":{"margin":{"top":"0"}}}} /--></div>
  <!-- /wp:group --></div>
  <!-- /wp:group -->

@bph bph added [Block] Navigation Affects the Navigation Block [Type] Bug An existing feature does not function as intended labels Dec 4, 2022
@bph
Copy link
Contributor Author

bph commented Dec 4, 2022

Might be related to this merged PR #46279 @getdave - I wonder if that is a backwards compatibility issue?

  • Note: 'parse_blocks' includes a null block with '\n\n' as the content when
  • it encounters whitespace. This is not a bug but rather how the parser
  • is designed.

@getdave
Copy link
Contributor

getdave commented Dec 5, 2022

Ok I'm looking into this now. Thanks for the ping! 🙇

@getdave
Copy link
Contributor

getdave commented Dec 5, 2022

Any chance you could send me the inner blocks of that Navigation Menu with the ID 740? To do this you can follow this guide.

@bph
Copy link
Contributor Author

bph commented Dec 5, 2022

Here is are the actual menu items. @getdave

<!-- wp:site-logo {"width":32,"style":{"color":{"duotone":["#F5F0E5","#FFFFFF"]}}} /-->	 <!-- wp:site-logo {"width":32,"style":{"color":{"duotone":["#F5F0E5","#FFFFFF"]}}} /-->
 <!-- wp:navigation-link {"label":"Home","type":"custom","url":"https://icodeforapurpose.com/","kind":"custom","isTopLevelLink":true} /-->
 <!-- wp:navigation-submenu {"label":"About Me","type":"page","id":3,"url":"https://icodeforapurpose.com/about/","kind":"post-type","isTopLevelItem":true} --> 
 <!-- wp:navigation-link {"label":"Uses","type":"page","id":68,"url":"https://icodeforapurpose.com/uses/","kind":"post-type","isTopLevelLink":false} /-->	 
 <!-- wp:navigation-link {"label":"Contact","type":"page","id":4,"url":"https://icodeforapurpose.com/contact/","kind":"post-type","isTopLevelLink":false} /-->
 <!-- /wp:navigation-submenu --> <!-- /wp:navigation-submenu -->  
 
 <!-- wp:social-links {"iconColor":"primary","iconColorValue":"#F5F0E5","openInNewTab":true,"className":"is-style-logos-only"} -->
 <ul class="wp-block-social-links has-icon-color is-style-logos-only"><!-- wp:social-link {"url":"https://twitter.com/bph","service":"twitter"} /-->
 <!-- wp:social-link {"url":"https://mastodon.social/@bph","service":"mastodon","rel":"me"} /--></ul>
 <!-- /wp:social-links --> 

Could it possibly be that the empty submenu that's causing the error?
<!-- /wp:navigation-submenu --> <!-- /wp:navigation-submenu -->

@getdave
Copy link
Contributor

getdave commented Dec 5, 2022

<!-- /wp:navigation-submenu --> <!-- /wp:navigation-submenu -->

The later tag is invalid and I guess should not be present. If a standalone block is desired then it should be:

<!-- wp:navigation-submenu /-->

This matches how HTML works.

Containing

<div>Hello world</div>

vs

Self closing

<div />

Notice the slash has moved to the end.

I don't know how this would have occurred in the block editor unless someone manually edited those blocks 🤔

Also having created a menu with these inner blocks, I don't see the error you are reporting on the front of the site.

@bph
Copy link
Contributor Author

bph commented Dec 5, 2022

Oh there might have been some editing hick-ups.
Here is the screenshot of the menu causing the fatal error.
Screen Shot 2022-12-05 at 09 47 07

@bph
Copy link
Contributor Author

bph commented Dec 6, 2022

And here is the code cleaned up.

<!-- wp:site-logo {"width":32,"style":{"color":{"duotone":
    ["#F5F0E5","#FFFFFF"]}}} /-->	
    
 <!-- wp:navigation-link {"label":"Home","type":"custom","url":"https://icodeforapurpose.com/",
    "kind":"custom","isTopLevelLink":true} /-->
 
<!-- wp:navigation-submenu {"label":"About 
        Me","type":"page","id":3,"url":"https://icodeforapurpose.com/about/",
        "kind":"post-type","isTopLevelItem":true} --> 
    <!-- wp:navigation-link {"label":"Uses","type":"page","id":68,"url":
        "https://icodeforapurpose.com/uses/","kind":"post-type","isTopLevelLink":false} /-->

    <!-- wp:navigation-link {"label":"Contact","type":"page","id":4,
        "url":"https://icodeforapurpose.com/contact/","kind":"post-type","isTopLevelLink":false} /-->
 <!-- /wp:navigation-submenu -->
 
 <!-- wp:social-links {"iconColor":"primary","iconColorValue":"#F5F0E5","openInNewTab":true,
    "className":"is-style-logos-only"} -->
    <ul class="wp-block-social-links has-icon-color is-style-logos-only">
        <!-- wp:social-link {"url":"https://twitter.com/bph","service":"twitter"} /-->
        <!-- wp:social-link {"url":"https://mastodon.social/@bph","service":"mastodon","rel":"me"} /-->
    </ul>
    <!-- /wp:social-links --> 

@scruffian
Copy link
Contributor

Potential fix here: WordPress/wordpress-develop#3731

@getdave
Copy link
Contributor

getdave commented Dec 7, 2022

And here #46374

@bph
Copy link
Contributor Author

bph commented Dec 12, 2022

This seems to have been fixed, since Dec 8th, 2022

@bph bph closed this as completed Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants