Deprecated function: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\Component\Utility\Bytes::toNumber()

Created on 4 October 2022, about 2 years ago
Updated 12 February 2024, 10 months ago

Problem/Motivation

File upload page have following errors:

Deprecated function: 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).
Drupal\Component\Utility\Bytes::toNumber(NULL) (Line: 77)
Drupal\Component\Utility\Bytes::toInt(NULL) (Line: 36)
Drupal\file_entity\Form\FileAddForm->getUploadValidators(Array) (Line: 132)
Drupal\file_entity\Form\FileAddForm->stepUpload(Array, Object, Array) (Line: 99)
Drupal\file_entity\Form\FileAddForm->buildForm(Array, Object, Array)

Steps to reproduce

- Enable and configure file entity module /admin/config/media/file-settings
- Leave the "Maximum upload size" field empty
- access the /file/add page

Proposed resolution

Use validation to handle this edge case

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇮🇳India ameymudras

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.

  • 🇮🇳India ameymudras

    Encountered this issue once more and proceeded to upgrade the module to version 2.0-rc5. However, the problem persists despite the update. After reviewing the modifications, it appears that resolving the issue requires either re-saving the settings form or altering the configuration from max_filesize: null to max_filesize: ''.

    For an existing installation undergoing an upgrade, this scenario applies. However, for a new installation, it functions seamlessly without encountering any issues.

  • Status changed to Needs review 10 months ago
Production build 0.71.5 2024