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

Created on 8 September 2023, over 1 year 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 about 5 hours 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 over 1 year ago
    29,471 pass
  • @leanderjcc opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year 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

Production build 0.71.5 2024