From 0496417d997dd09c05e9fc6518d506c87f5d12f4 Mon Sep 17 00:00:00 2001 From: Yaron Koren Date: Mon, 15 Jan 2024 04:06:15 +0000 Subject: [PATCH] Fix for PHP 8 (?) issue with round() For at least some configurations/version of PHP 8, round() can no longer be called on a string. So, we call round( floatval() ) on the value instead. Also remove the is_int() checks, since the value will presumably never be an integer per se - it is a string. Change-Id: I23b4512d21b97d573b1ef3737333cccff71670cc --- includes/CargoFieldDescription.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/includes/CargoFieldDescription.php b/includes/CargoFieldDescription.php index 000458e0..cc320f95 100644 --- a/includes/CargoFieldDescription.php +++ b/includes/CargoFieldDescription.php @@ -324,16 +324,12 @@ public function prepareAndValidateValue( $fieldValue ) { } $individualValues = explode( $delimiter, $fieldValue ); foreach ( $individualValues as &$individualValue ) { - if ( !is_int( $individualValue ) ) { - $individualValue = round( $individualValue ); - } + $individualValue = round( floatval( $individualValue ) ); } $newValue = implode( $delimiter, $individualValues ); } else { $newValue = str_replace( $wgCargoDigitGroupingCharacter, '', $fieldValue ); - if ( !is_int( $newValue ) ) { - $newValue = round( $newValue ); - } + $newValue = round( floatval( $newValue ) ); } } elseif ( $fieldType == 'Float' || $fieldType == 'Rating' ) { // Remove digit-grouping character, and change