Fix deprecated PHP 8.1 function: strpos(): Passing null to parameter #1 ($haystack) of type string

Created on 14 June 2022, over 2 years ago
Updated 11 September 2023, about 1 year ago

Problem/Motivation

When using PHP 8.1 with varbase_layout_builder the following Error message raised:

Error message
Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\varbase_layout_builder\Theme\VarbaseLayoutBuilderThemeNegotiator->applies() (line 79 of modules/contrib/varbase_layout_builder/src/Theme/VarbaseLayoutBuilderThemeNegotiator.php).
Drupal\varbase_layout_builder\Theme\VarbaseLayoutBuilderThemeNegotiator->applies(Object) (Line: 67)

Steps to reproduce

  1. Install Varbase Layout Builder
  2. Using PHP 8.1
  3. Using Drupal 9.3.15
  4. When using layout builder you will see the above error message

Proposed resolution

Check if the $route_name isn't null before the strpos() function in VarbaseLayoutBuilderThemeNegotiator.php

Remaining tasks

  • ✅ File an issue about this project
  • ✅ Addition/Change/Update/Fix to this project
  • ✅ Testing to ensure no regression
  • ➖ Automated unit/functional testing coverage
  • ➖ Developer Documentation support on feature change/addition
  • ➖ User Guide Documentation support on feature change/addition
  • ➖ Accessibility and Readability
  • ✅ Code review from 1 Varbase core team member
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Update Release Notes and Update Helper on new feature change/addition
  • ✅ Release varbase-9.0.7 , varbase_layout_builder-10.0.15

Varbase update type

  • ✅ No Update
  • ➖ Optional Update
  • ➖ Forced Update
  • ➖ Forced Update if Unchanged

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

🐛 Bug report
Status

Fixed

Version

10.0

Component

Code

Created by

🇯🇴Jordan Mohammad-Fayoumi Amman

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.71.5 2024