PHP 8.1 compatibility

Created on 14 October 2022, about 2 years ago
Updated 14 March 2023, almost 2 years ago

Problem/Motivation

When running under PHP 8.1, I get this deprecation warning:

Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\views_taxonomy_term_name_into_id\Plugin\views\argument_validator\TermNameAsId->validateArgument() (line 23 of modules/contrib/views_taxonomy_term_name_into_id/src/Plugin/views/argument_validator/TermNameAsId.php).
Drupal\views_taxonomy_term_name_into_id\Plugin\views\argument_validator\TermNameAsId->validateArgument(NULL) (Line: 1011)
Drupal\views\Plugin\views\argument\ArgumentPluginBase->validateArgument(NULL) (Line: 1046)
Drupal\views\Plugin\views\argument\ArgumentPluginBase->setArgument(NULL) (Line: 1101)
Drupal\views\ViewExecutable->_buildArguments() (Line: 1267)
Drupal\views\ViewExecutable->build(NULL) (Line: 1391)
Drupal\views\ViewExecutable->execute(NULL) (Line: 1454)
Drupal\views\ViewExecutable->render() (Line: 131)
Drupal\views\Plugin\views\display\Block->execute() (Line: 1630)
Drupal\views\ViewExecutable->executeDisplay('block_1', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array) (Line: 59)
Drupal\views\Plugin\Block\ViewsBlock->build() (Line: 171)
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func_array(Array, Array) (Line: 101)
...

Steps to reproduce

Install in PHP 8.1, clear cache and open a view that uses this module.

Proposed resolution

Coerce the argument to string to convert NULL values to strings (because third argument of str_replace should be string or array, but it gets called with NULL).

Remaining tasks

Testing

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡·πŸ‡΄Romania abautu

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