preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\Component\Utility\Bytes::toNumber() (line 93 of core/lib/Drupal/Component/Utility/Bytes.php)

Created on 21 July 2022, over 2 years ago
Updated 26 April 2023, over 1 year ago

Problem/Motivation

At times MediaBulkUploadForm::isMaxFileSizeLarger() passes a NULL value to Bytes::toNumber() which gives us the "preg_replace(): Passing null to parameter #3 ($subject)".
Possibly a thing since #3167373: Dropzone max filesize validation not working correctly .
Fixing the deprecation warning without changing the current behavior of the code is easy and I'll upload a patch shortly. But I'm not too deep into this project code and the warning may be a sign of a bug. Or maybe there's just a better fix. Possibly initializing $maxFileSizeForm to "0" when declaring this class property.

But as noted, the current behavior doesn't change when fixing the code to pass '' instead of NULL.

Steps to reproduce

Proposed resolution

Pass '' instead of NULL removes the deprecation warning but not the current behavior, because in this code path PHP will type juggle anyway.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇳🇱Netherlands Eric_A

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