views casetransform requires string in php 8.3

Created on 28 May 2025, 27 days 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

Merge Requests

Comments & Activities

  • Issue created by @matslats
  • How do we reproduce this so someone can write a regression test?

  • 🇳🇿New Zealand quietone

    If this problem was discovered on a version of Drupal that is not 11.x, add that information in the issue summary and leave the version at 11.x. In Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies . Also mentioned on the version section of the list of issue fields documentation.

  • 🇮🇳India kulpratap2002

    Working on it.

  • Pipeline finished with Success
    22 days ago
    Total: 506s
    #512854
  • 🇺🇸United States smustgrave

    Please check the tags before moving to review. Was previously tagged for steps to reproduce which are still needed.

    Thanks

  • This bug arose when I was building a glossary view reading some table cells which were empty.

  • First commit to issue fork.
  • Pipeline finished with Canceled
    15 days ago
    Total: 72s
    #517859
  • Pipeline finished with Failed
    15 days ago
    Total: 195s
    #517860
  • Pipeline finished with Success
    15 days ago
    Total: 553s
    #517871
  • Pipeline finished with Canceled
    14 days ago
    Total: 127s
    #518608
  • Pipeline finished with Failed
    14 days ago
    Total: 124s
    #518609
  • Pipeline finished with Failed
    14 days ago
    Total: 122s
    #518732
  • Pipeline finished with Failed
    14 days ago
    Total: 125s
    #518741
  • Pipeline finished with Failed
    14 days ago
    Total: 127s
    #518745
  • Pipeline finished with Failed
    14 days ago
    Total: 136s
    #518746
  • Pipeline finished with Failed
    14 days ago
    Total: 126s
    #518755
  • Pipeline finished with Failed
    14 days ago
    Total: 136s
    #518759
  • Pipeline finished with Failed
    14 days ago
    Total: 114s
    #518761
  • Pipeline finished with Success
    14 days ago
    Total: 465s
    #518766
  • 🇮🇳India JatinGupta40

    I have updated the code and added the test case and it is working fine, incorporating the necessary improvements.
    The new test case has been designed to ensure better validation and coverage. Additionally, I leveraged AI assistance to refine and enhance the implementation. Please review and let me know if any further adjustments or validations are required.

  • 🇳🇱Netherlands Lendude Amsterdam

    We still need to verify that this is a core bug, we need steps to reproduce and to make sure this statement in the IS is actually true:

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

    Why is that NULL? Is the bug that its NULL to begin with or that we are not checking for NULL?

Production build 0.71.5 2024