Deprecated function: str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated

Created on 8 September 2023, about 2 years ago

Problem/Motivation

We are getting deprecation notices on 404 pages

Deprecated function: str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\views\Plugin\views\display\DisplayPluginBase->viewExposedFormBlocks() (line 2642 of core/modules/views/src/Plugin/views/display/DisplayPluginBase.php).

It seems that in the function viewExposedFormBlocks it checks the route name to avoid views_ui. routes, but when \Drupal::routeMatch()->getRouteName() returns null it throws the deprecation notice in str_starts_with.

We are running PHP 8.1 with D10.1.2

Steps to reproduce

todo

Proposed resolution

Check the variable is not empty.

Remaining tasks

/

User interface changes

/

API changes

/

Data model changes

/

Release notes snippet

/

๐Ÿ› Bug report
Status

Active

Version

10.1 โœจ

Component
Viewsย  โ†’

Last updated 2 days ago

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium leanderjcc Ghent

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @leanderjcc
  • last update about 2 years ago
    29,471 pass
  • @leanderjcc opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review about 2 years ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium leanderjcc Ghent
  • Status changed to Needs work about 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Thanks for reporting.

    Will need steps to reproduce.

    Also would need to investigate why \Drupal::routeMatch()->getRouteName() is returning null. Could be masking a larger problem.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia karanpagare

    Tried to reproduce this but didn't face any issue

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance bertrandl

    IHello,

    I get same:
    Error message
    Deprecated function: str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\Core\Routing\UrlGenerator->generateFromRoute() (line 309 of core/lib/Drupal/Core/Routing/UrlGenerator.php).

    with :
    # Linux config
    $ hostnamectl
    Static hostname: deb-win
    Icon name: computer-desktop
    Chassis: desktop ๐Ÿ–ฅ๏ธ
    Machine ID: fafc07d395216ad0c3eee845473b7092
    Boot ID: a3e1cd31b982e29df762
    Operating System: Debian GNU/Linux 12 (bookworm)
    Kernel: Linux 6.1.0-27-amd64
    Architecture: x86-64
    Hardware Vendor: Dell Inc.
    Hardware Model: Precision Tower 5810
    Firmware Version: A20
    $ cat /etc/issue
    Debian GNU/Linux 12 \n \l

    $ cat /etc/os-release
    PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
    NAME="Debian GNU/Linux"
    VERSION_ID="12"
    VERSION="12 (bookworm)"
    VERSION_CODENAME=bookworm
    ID=debian
    HOME_URL="https://www.debian.org/"
    SUPPORT_URL="https://www.debian.org/support"
    BUG_REPORT_URL="https://bugs.debian.org/"
    $ lsb_release -crid
    No LSB modules are available.
    Distributor ID: Debian
    Description: Debian GNU/Linux 12 (bookworm)
    Release: 12
    Codename: bookworm

    # Drupal config
    $ drush core-status
    Drupal version : 10.3.10
    Site URI : http://default
    DB driver : mysql
    DB hostname : localhost
    DB port : 3306
    DB username : toomuch
    DB name : babxyz
    Database : Connected
    Drupal bootstrap : Successful
    Default theme : olivero
    Admin theme : claro
    PHP binary : /usr/bin/php8.2
    PHP config : /etc/php/8.2/cli/php.ini
    PHP OS : Linux
    PHP version : 8.2.25
    Drush script : /home/bertrand/projects/babxyz/vendor/bin/drush.php
    Drush version : 13.3.2.0
    Drush temp : /tmp
    Drush configs : /home/bertrand/.drush/drush.yml
    /home/bertrand/projects/babxyz/vendor/drush/drush/drush.yml
    Install profile : standard
    Drupal root : /home/bertrand/projects/babxyz/web
    Site path : sites/default
    Files, Public : sites/default/files/public
    Files, Private : sites/default/files/private
    Files, Temp : /tmp

    Bertrand

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine Yurii Novak
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    I observed this on a site, and found my way to this issue.

    On the affected site, the return value of $route_name = \Drupal::routeMatch()->getRouteName(); on the 404 page was NULL when this happened.

    Cross-checking on a different site, I saw that the route on a 404 page is system.404.

    I observed that on the affected site, the stack trace originated from BigPipe. When BigPipe module was disabled on the affected site, I was unable to reproduce the issue.

Production build 0.71.5 2024