Active
Project:
Accelerated Mobile Pages (AMP)
Version:
8.x-3.5
Component:
Miscellaneous
Priority:
Critical
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
24 Dec 2020 at 06:53 UTC
Updated:
27 Dec 2021 at 17:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
rajesh190888 commentedComment #3
nravens commentedI have the same issue, also Drupal 9
Have you found a solution?
Comment #4
pick_d commentedNot sure if it's AMP's or Metatag's issue.
Probably you have Metatag 8.x-1.15 installed. For me downgrading to Metatag 8.x-1.14 fixes the issue.
https://www.drupal.org/project/metatag/issues/3189863
Comment #5
nravens commentedSame issue and the same thing, rolling back to version 8.x-1.14 worked for me. Thank you.
Comment #6
rajesh190888 commentedI am using version 8.x-1.14 only
Comment #7
pkmedi commentedHmm - also facing this issue on 9.1.2 - downgrading was not sloving the issue.
The strange thing is i can see the canonical in incognito and logged in only on validating for Google amp, reports the error.
Comment #8
pkmedi commentedNot very common - but quick fix that did the trick... for anyone serves that issue...
Make a change in html.html.twig amptheme or sub and set it in directly in the theme:
after:
hope its helps somebody.
Comment #9
pick_d commentedpkmedi
Proposed change works for me, thanks a lot.
Comment #10
nravens commentedDo your AMP pages still validate with #8?
For some strange reason, validation error says rel="canonical" is duplicated but when I check page source it's only there once when using the suggestion in #8
Comment #11
pick_d commentedI reverted the change because at some point I got duplicated rel="canonical" issue.
So the fix mentioned in #8 worked well when module failed to do so. But when module works just fine, no need to apply #8. At least that how things work in my case.
Comment #12
makkus183 commentedI get the duplicated error @nravens mentioned in #10 in local dev environment. In Production Mode it is working fine when adding the link to the template as mentioned in #8
This behaviour remains the same regardless of being logged in or notEdit: I was wrong, it is duplicated when being logged in as mentioned by others before
Comment #13
jesmaster commentedI found the offending code and fixed the issue. If you've modified the template to force the line in then you can take it out.
Attached is the patch.
Comment #14
jesmaster commentedTo explain the error:
In PHP 7 (0 == 'string') will always return true
so it was mistaking the 0 key (which is typically the canonical url) as the "big_pipe_detect_nojs" key and removing it.
In PHP 8 this was fixed so (0 == 'string') will return false as expected which would explain why this issue seemed to randomly disappear for some people as they most likely upgraded to PHP 8 which fixed the logic.
So the simple fix here was to change it to a === check to ensure the type matches as well as the value which will fix the check for PHP7 and have no effect for PHP8.
Reference: https://stackoverflow.com/a/6843075
Comment #15
jsobiecki commentedI can confirm that patch from https://www.drupal.org/project/amp/issues/3189756#comment-14138468 solved issue for me.
Comment #16
damontgomery commentedThanks. I also had success with #13.
When we used `debug` in the URL, we got the canonical link, but when we didn't we did not get the link and the validation failed.
Thanks for the explanation for the issue. Maybe some people will be convinced to stop using `==`. :)
What happens is that if a string starts with a number, it casts to a number, but if it doesn't it casts to 0. The boolean FALSE casts to 0 and TRUE to 1. Then the integers are compared.
I think for some reason this was to support something like:
Comment #17
joshfeinstein commentedThe patch from June 2021 (#13) above fixes the AMP issue, but doesn't correctly address the big_pipe conditional. The correct value isn't $key, but $value[1].