[D7 PHP8.2] Deprecated function: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in drupal_strtolower(), line 529 in unicode.inc

Created on 11 January 2023, almost 2 years ago
Updated 4 October 2023, about 1 year ago

Problem & Steps to reproduce

I tried to update modules & theme under PHP 8.2, getting named error in the screen after download of update files, says it's in line 529 of includes/unicode.inc.

Proposed resolution

The code in this section of includes/unicode.inc is

function drupal_strtolower($text) {
  global $multibyte;
  if ($multibyte == UNICODE_MULTIBYTE) {
    return mb_strtolower($text);
  }
  else {
    // Use C-locale for ASCII-only lowercase
    $text = strtolower($text);
    // Case flip Latin-1 accented letters
    $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '_unicode_caseflip', $text);
    return $text;
  }
}

with return mb_strtolower($text); being line 529.

I suggest inserting $text = $text ? $text : ''; right before that line.
Any comments?

πŸ› Bug report
Status

Needs work

Version

7.0 ⚰️

Component
UpdateΒ  β†’

Last updated 1 day ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @tedbow
  • πŸ‡ΊπŸ‡ΈUnited States @dww
Created by

πŸ‡©πŸ‡ͺGermany upunkt

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡ΈπŸ‡°Slovakia sano

    There are more problematic places in that file, besides the one mentioned here. For example, I just run into:

    Deprecated: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /includes/unicode.inc on line 482

    referring to:

    function drupal_strlen($text) {
      global $multibyte;
      if ($multibyte == UNICODE_MULTIBYTE) {
        return mb_strlen($text);
      }
      else {
        // Do not count UTF-8 continuation bytes.
        return strlen(preg_replace("/[\x80-\xBF]/", '', $text));
      }
    }
    

    I encountered the error when adding a new action (adding a variable) into a rule, when clicking "Switch to data selection". The error appears in a JS dialog window.

  • πŸ‡ΈπŸ‡°Slovakia poker10

    @sano drupal_strlen() issue is being addressed here: πŸ› _form_validate sends null to drupal_strlen triggering deprecation notice Needs work , so any help/feedback is welcome. Thanks!

Production build 0.71.5 2024