stristr(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\amp\Service\AMPService::isDevPage()

Created on 2 November 2022, over 1 year ago
Updated 24 April 2023, about 1 year ago

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.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡¦πŸ‡·Argentina casivaagustin

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024