is_amp_endpoint was called incorrectly
-
I am adding virtual pages programmatically like seen here: https://gist.github.com/gmazzap/1efe17a8cb573e19c086
Sadly on the virtual pages the AMP plugin is creating a php notice of a too early called is_amp_endpoint() function:
Notice: is_amp_endpoint was called incorrectly. is_amp_endpoint() was called before the parse_query hook was called.Could you please look into this for a fix or give me a hint for a local fix.
Thanks alot.
-
I don’t see any instance of
is_amp_endpoint()in your Gist. Can you share the stack trace?The early function call is not in my code, it probably is in the AMP plugin itself?
Please share the error stack trace as that will indicate what part of your code is causing it to be called.
Hi,
this is the stack trace for the php notice:
[0] => Array( [function] => {closure} ) [1] => Array( [file] => /var/www/html/web/wp/wp-includes/functions.php [line] => 4986 [function] => trigger_error ) [2] => Array( [file] => /var/www/html/web/app/plugins/amp/includes/amp-helper-functions.php [line] => 273 [function] => _doing_it_wrong ) [3] => Array( [file] => /var/www/html/web/app/plugins/amp/amp.php [line] => 454 [function] => is_amp_endpoint ) [4] => Array( [file] => /var/www/html/web/wp/wp-includes/class-wp-hook.php [line] => 288 [function] => amp_maybe_add_actions ) [5] => Array ( [file] => /var/www/html/web/wp/wp-includes/class-wp-hook.php [line] => 312 [function] => apply_filters ) [6] => Array( [file] => /var/www/html/web/wp/wp-includes/plugin.php [line] => 478 [function] => do_action ) [7] => Array ( [file] => /var/www/html/web/app/mu-plugins/plugin-name/includes/Core/VirtualPages/Controller.class.php [line] => 31 [function] => do_action ) [8] => Array ( [file] => /var/www/html/web/wp/wp-includes/class-wp-hook.php [line] => 290 [function] => dispatch ) [9] => Array ( [file] => /var/www/html/web/wp/wp-includes/plugin.php [line] => 206 [function] => apply_filters ) [10] => Array ( [file] => /var/www/html/web/wp/wp-includes/class-wp.php [line] => 145 [function] => apply_filters ) [11] => Array ( [file] => /var/www/html/web/wp/wp-includes/class-wp.php [line] => 729 [function] => parse_request ) [12] => Array ( [file] => /var/www/html/web/wp/wp-includes/functions.php [line] => 1255 [function] => main ) [13] => Array ( [file] => /var/www/html/web/wp/wp-blog-header.php [line] => 16 [function] => wp ) [14] => Array ( [file] => /var/www/html/web/index.php [line] => 5 [function] => require )I already disabled every plugin (except AMP Plugin) and switched the theme (even though it doesnt contain any
is_amp_endpoint()call anyways.I redacted the args of the stack trace for readability and to prevent leaking of sensible data. If you need the full stack trace with arguments please let me know how to share it with you privately.
If you are wondering about the file paths: They are from my WP Bedrock setup, but this should not cause the issue here.
// Edit: Added all steps of stack trace, previous one was truncated.
-
This reply was modified 6 years, 4 months ago by
schwifty5.
Index 7 of the stack trace is refering to this line btw: https://gist.github.com/gmazzap/1efe17a8cb573e19c086#file-controller-php-L34
OK, your custom router code is doing the
parse_requestaction andwpaction, but it is not also doing theparse_queryaction. That is resulting in the notice:Add a
do_action( 'parse_query', $wp );as well, and that should eliminate the notice.Thank you, this has indeed solved the issue.
The dispatch function of my controller now looks like this (is this the correct order / params?):
function dispatch($bool, \WP $wp) { if ($this->checkRequest() && $this->matched instanceof Page) { global $wp_query; $this->loader->init($this->matched); $wp->virtual_page = $this->matched; do_action('parse_request', $wp); do_action('parse_query', $wp_query); $this->setupQuery(); do_action('wp', $wp); $this->loader->load(); $this->handleExit(); } return $bool; }Thanks for that awesome and rapid support!
Yes, that looks good.
We’d appreciate a plugin review!
Thanks so much. Happy to leave you a very well deserved review.
-
This reply was modified 6 years, 4 months ago by
The topic ‘is_amp_endpoint was called incorrectly’ is closed to new replies.