Using Drupal on PHP 8.1, the module throws this warning.
Deprecated function: stristr(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\amp\Service\AMPService::isDevPage() (line 173 of modules/contrib/amp/src/Service/AMPService.php).
That happens because AMPService::isDevPage() calls \Drupal::request()->getQueryString() and passes the values it return to stristr(), which doesn't accept anymore a NULL value, on PHP 8.1.
Before calling stristr(), the code needs to check the passed argument isn't NULL or cast that value to a string. In this way, NULL will be converted to an empty string.
Comments
Comment #2
avpadernoComment #3
avpadernoComment #4
avpadernoComment #5
ankitjhakal commentedComment #6
ankitjhakal commentedTested and applied patch on local. Issue is resolved after applying patch. So changing status of it.
Comment #7
berdirDuplicate of #3263406: stristr(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\amp\Service\AMPService::isDevPage()
The other patch has strange formatting though, so maybe makes more sense to commit this.
Comment #8
pick_d commentedPatch works for me as well (Drupal 9.5.1, PHP 8.1.13).
Thanks a lot.
Comment #9
littlepixiez commentedPatch works for me! Fixes deprecation errors on PHP 8.1. Thanks @casivaagustin
Comment #10
phjouPatch works for me as well, it would be great to be merged, thank you.
Comment #11
e0ipsoI just created (then closed) a duplicate of this #3356049: stristr(): Passing null to parameter #1 ($haystack) of type string is deprecated in AMPService::isDevPage(). I am facing this issue as well.
Comment #13
m4oliveiThanks everyone!
Committed to 8.x-3.x. I'll tag a release shortly.