• Resolved xelan54

    (@xelan54)


    Hello,

    AMP 1.5.2 completely breaks my site:

    Notice: is_amp_endpoint was called incorrectly. is_amp_endpoint() was called before the wp action which means it will not have access to the queried object to determine if it is an AMP response, thus neither the amp_skip_post filter nor the AMP enabled publish metabox toggle will be considered. Please see Debugging in WordPress for more information. (This message was added in version 1.0.2.) in /var/www/html/wp-includes/functions.php on line 5167

    This blog is running a plain vanilla version of TwentyNineteen via a child theme that makes very few changes (simply because I’m incapable of learning CSS no matter how hard I try).

    AMP was fine until 1.5.2.

    Can someone help me figure out what changed and maybe offer a clue of how to fix it? The plug-in is (temporarily) deactivated.

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 16 through 30 (of 34 total)
  • It may be a three-way plugin conflict. We also have plugins/advanced-ads, which calls is_admin_bar_showing() on the action plugins_loaded.

    The trace goes like this:

    3.file: '.../wp-includes/functions.php'
    3.function: 'do_action'
    3.args: 'array(doing_it_wrong_run, is_amp_endpoint, is_amp_endpoint() was called before the parse_query hook was called., 0.4.2)'
    
    4.file: '.../wp-content/plugins/amp/includes/amp-helper-functions.php'
    4.function: '_doing_it_wrong'
    4.args: 'array(is_amp_endpoint, is_amp_endpoint() was called before the parse_query hook was called., 0.4.2)'
    
    5.file: '.../wp-content/plugins/jetpack/3rd-party/class.jetpack-amp-support.php'
    5.function: 'is_amp_endpoint'
    
    6.file: '.../wp-content/plugins/jetpack/3rd-party/class.jetpack-amp-support.php'
    6.function: 'is_amp_request'
    6.class: 'Jetpack_AMP_Support'
    
    7.file: '.../wp-includes/class-wp-hook.php'
    7.function: 'show_admin_bar'
    7.class: 'Jetpack_AMP_Support'
    
    8.file: '.../wp-includes/plugin.php'
    8.function: 'apply_filters'
    
    9.file: '.../wp-includes/admin-bar.php'
    9.function: 'apply_filters'
    9.args: 'array(show_admin_bar, 1)'
    
    10.file: '.../wp-content/plugins/advanced-ads/classes/frontend_checks.php'
    10.function: 'is_admin_bar_showing'

    Thanks @westonrute, we patched Jetpack to do the same thing. Because the output from WP_DEBUG is too much trouble for me, and I don’t think the workaround plugin could stop that. Also fills up our error_log.

    In other words, we patched
    plugins/jetpack/3rd-party/class.jetpack-amp-support.php

    as follows:

    public static function is_amp_request() {
    	// xxx temp fix
    	if ( ! did_action( 'parse_query' ) ) {
    		return false;
    	}
    	// end temp fix xxx
    	$is_amp_request = ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() );
    • This reply was modified 4 years, 7 months ago by kitchin.
    Plugin Author Weston Ruter

    (@westonruter)

    I’m going to look into these issues and open issues/PRs for Jetpack where required.

    Plugin Author Weston Ruter

    (@westonruter)

    Does rolling back Jetpack to 8.3.x make this issue go away?

    By code inspection it seems likely. These three filters were added in Jetpack 8.4.

    add_action( 'the_content', array( 'Jetpack_AMP_Support', 'disable_comment_likes_before_the_content' ) );

    add_filter( 'show_admin_bar', array( 'Jetpack_AMP_Support', 'show_admin_bar' ) );

    add_filter( 'jetpack_comment_likes_enabled', array( 'Jetpack_AMP_Support', 'comment_likes_enabled' ) );

    (The 1st action would normally be written as filter, but maybe Jetpack devs want to emphasize it doesn’t change $content.)

    The codepath for the WP_DEBUG I see goes through the 2nd filter.

    Our “Notice” error was slightly different from the original in this thread. We had:

    Notice: is_amp_endpoint was called incorrectly. is_amp_endpoint() was called before the parse_query hook was called.

    Both notices originate in the same function, is_amp_endpoint(), as does this one:

    Notice: is_amp_endpoint was called incorrectly. is_amp_endpoint() was called before the WP_Query was instantiated.

    • This reply was modified 4 years, 7 months ago by kitchin.
    • This reply was modified 4 years, 7 months ago by kitchin.
    Plugin Author Weston Ruter

    (@westonruter)

    @kitchin @xelan54 This plugin code should prevent the notice from happening for you:

    // Unhook the show_admin_bar filter added in Jetpack_AMP_Support::init().
    add_action(
    	'init',
    	function () {
    		remove_filter( 'show_admin_bar', [ 'Jetpack_AMP_Support', 'show_admin_bar' ] );
    	},
    	2 // Because Jetpack_AMP_Support::init() happens at priority 1.
    );

    This is removing the filter which will get removed in Jetpack as well in the next release, per https://github.com/Automattic/jetpack/pull/15372

    Plugin Author Weston Ruter

    (@westonruter)

    Thread Starter xelan54

    (@xelan54)

    Thank you very much for the effort.

    Unfortunately, no joy in my case.

    Plugin Author Weston Ruter

    (@westonruter)

    And if you deactivate Jetpack but leave the AMP plugin active, the issue goes away?

    I have Jetpack active with the cookie consent widget in the sidebar, along with AMP and my workaround plugins, and I get no PHP notices for is_amp_endpoint().

    If you have those plugins all active and then deactivate other active plugins one-by-one, does that ultimately cause the notices to go away? If so, do they go away with one plugin being deactivated in particular? I could provide a workaround plugin for that as well if I knew what plugin is causing the problem.

    Thread Starter xelan54

    (@xelan54)

    I got lucky. I only had to disable the second plugin in the UI.

    It’s always “the other guy“. ??

    We should probably just send the AIO SEO folks the link to this discussion and let you get some sleep, @westonruter.

    Plugin Author Weston Ruter

    (@westonruter)

    @xelan54 I have one more plugin for you to install which will help identify specifically who is responsible for calling is_amp_endpoint() incorrectly.

    Please install this plugin (installation instructions linked in comment): https://gist.github.com/westonruter/4bc22394cf5362acb9e78946332b6498

    Once installed and you are logged-in as an administrator, whenever is_amp_endpoint() is called incorrectly, you’ll see something like this added to the page:

    Notice: is_amp_endpoint() was called prematurely.
    Hook stack: init, show_admin_bar
    Backtrace: #0  AMP_Doing_Endpoint_Check_Wrong_Debugging\{closure}(is_amp_endpoint) called at [/app/public/core-dev/src/wp-includes/class-wp-hook.php:289]
    #1  WP_Hook->apply_filters(, Array ([0] => is_amp_endpoint,[1] => is_amp_endpoint() was called before the wp action which means it will not have access to the queried object to determine if it is an AMP response, thus neither the amp_skip_post filter nor the AMP enabled publish metabox toggle will be considered.,[2] => 1.0.2)) called at [/app/public/core-dev/src/wp-includes/class-wp-hook.php:311]
    #2  WP_Hook->do_action(Array ([0] => is_amp_endpoint,[1] => is_amp_endpoint() was called before the wp action which means it will not have access to the queried object to determine if it is an AMP response, thus neither the amp_skip_post filter nor the AMP enabled publish metabox toggle will be considered.,[2] => 1.0.2)) called at [/app/public/core-dev/src/wp-includes/plugin.php:478]
    #3  do_action(doing_it_wrong_run, is_amp_endpoint, is_amp_endpoint() was called before the wp action which means it will not have access to the queried object to determine if it is an AMP response, thus neither the amp_skip_post filter nor the AMP enabled publish metabox toggle will be considered., 1.0.2) called at [/app/public/core-dev/src/wp-includes/functions.php:5142]
    #4  _doing_it_wrong(is_amp_endpoint, is_amp_endpoint() was called before the wp action which means it will not have access to the queried object to determine if it is an AMP response, thus neither the amp_skip_post filter nor the AMP enabled publish metabox toggle will be considered., 1.0.2) called at [/app/public/content/plugins/amp/includes/amp-helper-functions.php:645]
    #5  is_amp_endpoint() called at [/app/public/content/plugins/jetpack/3rd-party/class.jetpack-amp-support.php:104]
    #6  Jetpack_AMP_Support::is_amp_request() called at [/app/public/content/plugins/jetpack/3rd-party/class.jetpack-amp-support.php:68]
    #7  Jetpack_AMP_Support::show_admin_bar(1) called at [/app/public/core-dev/src/wp-includes/class-wp-hook.php:287]
    #8  WP_Hook->apply_filters(1, Array ([0] => 1)) called at [/app/public/core-dev/src/wp-includes/plugin.php:206]
    #9  apply_filters(show_admin_bar, 1) called at [/app/public/core-dev/src/wp-includes/admin-bar.php:1224]
    #10 is_admin_bar_showing() called at [/app/public/core-dev/src/wp-includes/class-wp-hook.php:287]
    #11 WP_Hook->apply_filters(, Array ([0] => )) called at [/app/public/core-dev/src/wp-includes/class-wp-hook.php:311]
    #12 WP_Hook->do_action(Array ([0] => )) called at [/app/public/core-dev/src/wp-includes/plugin.php:478]
    #13 do_action(init) called at [/app/public/core-dev/src/wp-settings.php:540]
    #14 require_once(/app/public/core-dev/src/wp-settings.php) called at [/app/public/core-dev/wp-config.php:3]
    #15 require_once(/app/public/core-dev/wp-config.php) called at [/app/public/core-dev/src/wp-load.php:42]
    #16 require_once(/app/public/core-dev/src/wp-load.php) called at [/app/public/core-dev/src/wp-blog-header.php:13]
    #17 require(/app/public/core-dev/src/wp-blog-header.php) called at [/app/public/index.php:24]

    Please share what this outputs for you.

    Thread Starter xelan54

    (@xelan54)

    Here’s the output, @westonruter. Thanks for all your work on my behalf.

    Notice: is_amp_endpoint() was called prematurely.
    Hook stack: init, show_admin_bar
    Backtrace: #0  AMP_Doing_Endpoint_Check_Wrong_Debugging\{closure}(is_amp_endpoint) called at [/var/www/html/wp-includes/class-wp-hook.php:289]
    #1  WP_Hook->apply_filters(, Array ([0] => is_amp_endpoint,[1] => is_amp_endpoint() was called before the parse_query hook was called.,[2] => 0.4.2)) called at [/var/www/html/wp-includes/class-wp-hook.php:311]
    #2  WP_Hook->do_action(Array ([0] => is_amp_endpoint,[1] => is_amp_endpoint() was called before the parse_query hook was called.,[2] => 0.4.2)) called at [/var/www/html/wp-includes/plugin.php:478]
    #3  do_action(doing_it_wrong_run, is_amp_endpoint, is_amp_endpoint() was called before the parse_query hook was called., 0.4.2) called at [/var/www/html/wp-includes/functions.php:5131]
    #4  _doing_it_wrong(is_amp_endpoint, is_amp_endpoint() was called before the parse_query hook was called., 0.4.2) called at [/var/www/html/wp-content/plugins/amp/includes/amp-helper-functions.php:589]
    #5  is_amp_endpoint() called at [/var/www/html/wp-content/plugins/jetpack/3rd-party/class.jetpack-amp-support.php:103]
    #6  Jetpack_AMP_Support::is_amp_request() called at [/var/www/html/wp-content/plugins/jetpack/3rd-party/class.jetpack-amp-support.php:67]
    #7  Jetpack_AMP_Support::show_admin_bar(1) called at [/var/www/html/wp-includes/class-wp-hook.php:287]
    #8  WP_Hook->apply_filters(1, Array ([0] => 1)) called at [/var/www/html/wp-includes/plugin.php:206]
    #9  apply_filters(show_admin_bar, 1) called at [/var/www/html/wp-includes/admin-bar.php:1224]
    #10 is_admin_bar_showing() called at [/var/www/html/wp-content/plugins/all-in-one-seo-pack/admin/aioseop_module_manager.php:170]
    #11 All_in_One_SEO_Pack_Module_Manager->do_load_module(feature_manager, Array ([0] => sitemap,[1] => opengraph,[2] => robots,[3] => file_editor,[4] => importer_exporter,[5] => bad_robots,[6] => performance,[7] => video_sitemap,[8] => image_seo)) called at [/var/www/html/wp-content/plugins/all-in-one-seo-pack/admin/aioseop_module_manager.php:95]
    #12 All_in_One_SEO_Pack_Module_Manager->__construct(Array ([0] => sitemap,[1] => opengraph,[2] => robots,[3] => file_editor,[4] => importer_exporter,[5] => bad_robots,[6] => performance,[7] => video_sitemap,[8] => image_seo)) called at [/var/www/html/wp-content/plugins/all-in-one-seo-pack/inc/aioseop_functions.php:42]
    #13 aioseop_load_modules() called at [/var/www/html/wp-includes/class-wp-hook.php:287]
    #14 WP_Hook->apply_filters(, Array ([0] => )) called at [/var/www/html/wp-includes/class-wp-hook.php:311]
    #15 WP_Hook->do_action(Array ([0] => )) called at [/var/www/html/wp-includes/plugin.php:478]
    #16 do_action(init) called at [/var/www/html/wp-settings.php:540]
    #17 require_once(/var/www/html/wp-settings.php) called at [/var/www/html/wp-config.php:89]
    #18 require_once(/var/www/html/wp-config.php) called at [/var/www/html/wp-load.php:37]
    #19 require_once(/var/www/html/wp-load.php) called at [/var/www/html/wp-blog-header.php:13]
    #20 require(/var/www/html/wp-blog-header.php) called at [/var/www/html/index.php:17]
    Plugin Author Weston Ruter

    (@westonruter)

    @xelan54 I see the problem. I was using an old version of AIO SEO. After updating I was able to reproduce the problem. The latest version does add_action( 'init', 'aioseop_load_modules', 1 ) which is too early for my workaround plugin to work as written.

    I’ve reworked it now to make sure that the admin-bar filter gets unhooked even earlier. Please uninstall the workaround plugin and install this updated version: https://gist.github.com/westonruter/d168c290d6c01c107da960d48fa3dad3

Viewing 15 replies - 16 through 30 (of 34 total)
  • The topic ‘AMP 1.5.2 completely breaks site’ is closed to new replies.