Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293242

Deprecated function: abs(): Passing null to parameter #1 ($num) of type int|float is deprecated in format_size()

$
0
0

Problem/Motivation

The file_managed.filesize column could be null, if the file size couldn't be determined. So we need to check that the file size is not null before passing to format_size(), which expects an integer.

The PHP 8.1 error messages are: Deprecated function: abs(): Passing null to parameter #1 ($num) of type int|float is deprecated in format_size() (line 138 of core/includes/common.inc) and Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php) - there are two deprecations because the null size is also passed thru htmlspecialchars() as the @count placeholder. (Hmm, having strict type checking someday in format_size() would prevent the need to pass the number thru htmlspecialchars() :)

Steps to reproduce

Create a File entity with null size (e.g. file doesn't exist or can't be statted), and use it with the table of files field formatter.


Viewing all articles
Browse latest Browse all 293242

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>