views casetransform requires string in php 8.3

Created on 28 May 2025, 1 day ago

in Drupal\views\Plugin\views\HandlerBase we find this function

  protected function caseTransform($string, $option) {
    switch ($option) {
      default:
        return $string;
      case 'upper':
        return mb_strtoupper($string);

      case 'lower':
        return mb_strtolower($string);

      case 'ucfirst':
        return Unicode::ucfirst($string);

      case 'ucwords':
        return Unicode::ucwords($string);
    }
  }

In php 8.3 those mb_function require a string, but the $string argument is untyped, so if $string is NULL, we get this warning:
Deprecated function: mb_strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated

The above function is called by Drupal\views\Plugin\views\argument\StringArgument::summaryArgument();

$value = $this->caseTransform($data->{$this->base_alias}, $this->options['path_case']);

and it is possible that $data->{$this->base_alias} can be NULL

Solution: check that $data->{$this->base_alias} is not empty before calling caseTransform.

🐛 Bug report
Status

Active

Version

10.5

Component

views.module

Created by

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

Comments & Activities

Production build 0.71.5 2024