-
Notifications
You must be signed in to change notification settings - Fork 384
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
Error caused by using is_embed() and is_feed() in is_amp_endpoint() before condition (! $did_parse_query) #4525
Comments
Would you like to open a pull request to implement what you are proposing? |
I can try. It would be my first time pulling. :) |
Thanks. We'll be happy to help you iterate on the PR. |
I'm trying to clone the repository, but get en error and it won't clone (the result is an empty folder). Probably caused by the space in the path (see below). It seems something in the repo. error: invalid path 'lib/optimizer/tests/spec/transformers/valid/ServerSideRendering/boilerplate_not_removed_when_amp_experiment_present/input.html /input.html' |
Thanks. It looks like you've identified a bug in how we're syncing the test suite down. Namely, in |
@hansschuijff We have a fix in #4527. Could you try cloning that branch? Assuming you cloned from git fetch origin && git checkout update-test-specs |
I went ahead and merged that pull request, so you can just pull down the latest commits from the |
Thank you, I am able to clone now. |
@hansschuijff Any update on this? |
Moved checking against is_embed() and is_feed() after checking if parse_query has run and $wp_query has been filled, since both these functions will fire _doing_it_wrong when $wp_query is not yet set.
Hi Weston, Also running nmp install and npm run dev and then npm run build didn't work for me, and it reported errors I was not capable in solving yet. So it might just be that the dev env for me is yet too complex/advanced. Sorry for that. It cost me more time than I would have liked without the result I sought. Probably I need to pipe the script through something on a windows platform, but I didn't know how to do that. I guess most of you develop on a unix or Mac platform that don't have this problem. A lot of effort for such a tiny edit. I have made the change and a pull request and tested the code by just changing it too in the installable version of the plugin. So I think this must be it then. In the code of is_embed() and is_feed() I read that they fire doing it wrong when $wp_query isn't set, so moving those to below like in the pull request results in better error logging. Hope this helps. Let me know if I need to change something. |
By the way: the pull request comment points to documentation links (behind the checkboxes) that no longer exist. Perhaps you want to change that too? |
Thanks for letting us know, I've created an issue for that: #4575 |
(Re-opening for QA purposes) |
Bug Description
When calling is_amp_endpoints() at an early stage in a plugin, the conditionals is_embed() en is_feed() issue an error notice, saying it can't be used before the query is finished. It doesn't reach the code that is used to test if the function is started too early, so the cause is unclear at first.
Expected Behaviour
The function tests if it is started before the 'parse_query' hook and starts doing_it_wrong saying is_amp_endpoint() it is started to early in the process. This would be the intended behaviour when it is started too early. it would be solved by moving the if(! $did_parse_query) block up so it runs and before testing the template tags. now it doesn't reach that test depending on how early it is called.
Steps to reproduce
Screenshots
the notice is:
is_embed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.)
Additional context
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
QA testing instructions
Demo
Changelog entry
_doing_it_wrong()
message for whenis_amp_endpoint()
is called before thewp
action.is_comment_feed()
,is_trackback()
,is_robots()
, andis_favicon()
.is_amp_endpoint()
to not emit_doing_it_wrong()
when called beforewp
when in Reader mode._doing_it_wrong()
errors when by callingis_embed()
oris_feed()
before they are able to be called.exit
logic.page_for_posts
if designated to be enabled in AMP Reader mode.The text was updated successfully, but these errors were encountered: