Support » Plugin: AMP » gutenberg 10.6.0 + AMP 2.1.0 fatal error

  • Resolved nobita

    (@nobita)


    gutenberg 10.6.0
    AMP 2.1.0
    WordPress 5.7.2

    
    PHP Fatal error:  ob_start(): Cannot use output buffering in output buffering display handlers in /virtual/***7/wp-content/plugins/gutenberg/build/block-library/blocks/post-comments-form.php on line 26
    

    function gutenberg_render_block_core_post_comments_form() using ob_start()

    not be able to view the AMP page.

    Please give me some advice on how to display the AMP page proper

    Thank you.

    • This topic was modified 8 months, 1 week ago by nobita.
Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @nobita

    first can you please update the AMP plugin to 2.1.1 and let us know if that resolves your issue.

    I am unable to reproduce this issue at my end I tested with AMP 2.1.0 and WP 5.7.2 and TwentryTwentyOne theme.

    Can you please let us know if you are using Comment block or it’s just the theme comment section that not getting rendered properly?

    Additionally, please send us your PHP error log ( the error part only), site URL, and site health info using this form so we can investigate it further.

    2.1.1 plugin is broken too

    revert these changes. can’t you see how many websites you’re breaking!

    I submitted my issue to that form DAYS ago and have yet to receive a response
    why are you lying to so many people

    • This reply was modified 8 months, 1 week ago by dlynch027.
    Plugin Support Bethany Chobanian Lang

    (@shetheliving)

    @dlynch027 While I definitely understand your frustration, it’s disruptive for other users when you reply within their topic about your issue. We’re happy to help troubleshoot with you, but in addition to completing the Site Health form, we also need you to open a new support topic so that we can work with you directly. While others may be experiencing the same issues as you, the reason and fix may be different depending on your site setup.

    Thank you!

    Plugin Author Weston Ruter

    (@westonruter)

    @dlynch027 Also, I still don’t see that you’ve opened a support topic yet. I did seem to find your form submission, but it was hard to find because it wasn’t part of your own topic. When you open a topic, please detail what specifically is broken, if you’re seeing this same issue as reported here. Your form submission doesn’t include any PHP error log information, so if there was a fatal error that would be helpful to include in another form submission.

    Plugin Author Weston Ruter

    (@westonruter)

    The gutenberg_render_block_core_post_comments_form() function is located here: https://plugins.trac.wordpress.org/browser/gutenberg/tags/10.6.0/build/block-library/blocks/post-comments-form.php

    It’s part of the core/post-comments-form block which is essentially part of Full Site Editing.

    Nevertheless, I’m able to add it to content and view the block on an AMP page, when using Twenty Twenty-One in Transitional mode and when using AMP Legacy Reader theme. I’m not seeing any such fatal error.

    @nobita Please do submit your Site Health information via our private submission from so we can try to replicate what you’re seeing: https://forms.gle/Jods9ka5BToPBa23A

    Thread Starter nobita

    (@nobita)

    @milindmore22
    @westonruter

    AMP Plugin Escalations sent
    Plugin update 2.1.1

    Twenty Twenty, Twenty Twenty one seems to work fine.

    It does not work with the following themes. (Is my theme)

    https://wordpress.org/themes/emulsion/

    live example: https://www.tenman.info/wp3/emulsion/2021/05/14/amp-test/

    Note:This theme is used at the same time as the following plugins.

    https://wordpress.org/plugins/emulsion-addons/

    Thank you.

    • This reply was modified 8 months, 1 week ago by nobita.
    Plugin Author Weston Ruter

    (@westonruter)

    @nobita I tried installing the Emulsion theme and the Emulsion Addons plugin and I didn’t get any error. Have you configured the theme and plugin in any particular way?

    The only issue I saw is that there are warnings due to is_page() and is_amp_endpoint() being called too early.

    These changes seem to fix that issue.

    Theme:

    --- a/lib/hooks.php
    +++ b/lib/hooks.php
    @@ -41,7 +41,11 @@ function emulsion_hooks_setup() {
     	/**
     	 * Scripts
     	 */
    -	false === emulsion_is_amp() ? add_filter( 'emulsion_inline_script', 'emulsion_get_rest' ) : '';
    +	add_action( 'wp', static function () {
    +		if ( emulsion_is_amp() ) {
    +			add_filter( 'emulsion_inline_script', 'emulsion_get_rest' );
    +		}
    +	} );
     	true === emulsion_the_theme_supports( 'lazyload' ) ? add_filter( 'emulsion_lazyload_script', 'emulsion_lazyload' ) : '';
     	true === emulsion_the_theme_supports( 'instantclick' ) ? add_filter( 'emulsion_instantclick_script', 'emulsion_instantclick' ) : '';

    Plugin:

    --- a/includes/metabox.php
    +++ b/includes/metabox.php
    @@ -113,7 +113,7 @@ class emulsion_add_meta_boxes {
     		add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
     		add_action( 'save_post', array( $this, 'save' ) );
     		add_action( 'rest_api_init', array( $this, 'rest_save' ) );
    -		$this->metabox_display_control();
    +		add_action( 'wp', array( $this, 'metabox_display_control' ) );
     	}
     
     	public function metabox_display_control() {
    • This reply was modified 8 months, 1 week ago by Weston Ruter.
    Plugin Author Weston Ruter

    (@westonruter)

    I’m testing with both the theme and plugin active, on a post that I’ve added the Post Comments Form block:

    <!-- wp:post-comments-form /-->

    But I’m not seeing any fatal error. The page is rendered as a valid AMP page.

    Plugin Author Weston Ruter

    (@westonruter)

    I’m narrowing down where I think the issue is coming from. It seems to be due to the content, which includes the Post Comments Form block, being included in the Schema.org markup. When this happens, and do_blocks() happens, then the ob_start() call in the block’s render_callback happens, and this causes an error when it is happening in the output buffer callback for the entire page. I’m still working to isolate how to replicate the issue.

    Plugin Author Weston Ruter

    (@westonruter)

    I still can’t configure my site to trigger the error, but I can reproduce the issue in Twenty Twenty-One using the following plugin code:

    add_filter( 'amp_schemaorg_metadata', function ( $metadata ) {
    	$metadata['rendered_post_comments_form'] = do_blocks( '<!-- wp:post-comments-form /-->' );
    	return $metadata;
    } );

    I’ve filed an issue to fix this: https://github.com/ampproject/amp-wp/issues/6232

    Plugin Author Weston Ruter

    (@westonruter)

    I’ve opened a pull request to fix this: https://github.com/ampproject/amp-wp/pull/6233

    As a quick fix, if you comment out this filter it should prevent the error from happening:

    add_filter( 'amp_post_template_metadata', 'emulsion_amp_description', 10, 2 );

    Since my fix should be in the 2.1.2 release, you could conditionally add that filter if version_compare( AMP_VERSION, '2.1.2', '>=' ). Or inside of emulsion_meta_description() you could remove the call to wp_trim_excerpt() which is calling excerpt_remove_blocks() and is currently causing the fatal, I believe.

    Plugin Author Weston Ruter

    (@westonruter)

    A 2.2-alpha build is available for testing: https://github.com/ampproject/amp-wp/pull/6233#issuecomment-841041568

    @nobita Please confirm if this fixes the issue for you.

    One that is merged, then I’ll merge it into the 2.1 branch so it will be part of 2.1.2.

    Thread Starter nobita

    (@nobita)

    @westonruter

    solved

    thank you very much.

    Plugin Author Weston Ruter

    (@westonruter)

    Thanks for testing!

    I’ve merged the PR and squashed the commits into the 2.1 branch. It’ll shortly be available in the 2.1.x builds linked to from our Development Builds page.

    The 2.1.2 release will either be out today or early next week.

    Plugin Author Weston Ruter

    (@westonruter)

    v2.1.2 is now published on WordPress.org

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘gutenberg 10.6.0 + AMP 2.1.0 fatal error’ is closed to new replies.