Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
file.module
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Oct 2021 at 08:37 UTC
Updated:
16 Oct 2021 at 03:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
alexpottHere's the fix from the meta.
Comment #3
daffie commentedCan we update the docblock of the function
format_size()that the first parameter must be a int or a float. Can we also do a check for that and throw a deprecation warning when this is not the case. See: https://www.php.net/manual/en/function.abs.phpComment #4
alexpott@daffie it can be a string too... which it nearly always is... see https://3v4l.org/ejYM6
Comment #5
alexpottI think the question here is not about format_size() but about whether the fix should be in \Drupal\file\Entity\File::getSize() or template_preprocess_file_link()
Comment #6
daffie commentedFrom core/includes/common.inc:
and PHP defines the functions
abs()asabs(int|float $num): int|float. Therefor the variable$sizemust be an integer value or a float value. It is not saying anything about allowing string values.Comment #7
alexpott@daffie see https://3v4l.org/ejYM6 - not all PHP docs are correct.
Comment #8
andypostI bet it because PHP using internal conversion from strings to numbers, I bet because https://wiki.php.net/rfc/string_to_number_comparison
No need to fix docs for function which is going to be deprecated (naming question) #2157945: Deprecate format_size() and use Drupal\Core\StringTranslation\ByteSizeMarkup instead
The issue fixes the problem as #7 points with BC so no CR needed
Comment #9
larowlanCommitted 01a737b and pushed to 9.3.x. Thanks!