Fix deprecated PHP 8.1 function: strpos(): Passing null to parameter No. 1 ($haystack) of type string on the Old VLB ~9.0

Created on 12 September 2023, about 1 year ago
Updated 15 October 2023, about 1 year ago

Problem/Motivation

Follow up for issue 🐛 Fix deprecated PHP 8.1 function: strpos(): Passing null to parameter #1 ($haystack) of type string Fixed

When using PHP 8.1 with varbase_layout_builder 9.0.x the following Error message was 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

Install Varbase Layout Builder
Using PHP 8.1
Using Drupal 9.5.10
When using Layout Builder 9.0.x you will get 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.16 , varbase_layout_builder-9.0.11

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

  • Issue #3386649 by YazanMajadba : Fixed deprecated PHP 8.1 function: strpos(): Passing null to parameter No. 1 ($haystack) of type string on the Old VLB ~9.0
🐛 Bug report
Status

Fixed

Version

9.0

Component

Code

Created by

🇯🇴Jordan YazanMajadba

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

Production build 0.71.5 2024