Skip to content

Commit

Permalink
Fix for PHP 8 (?) issue with round()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yaronkoren authored and mszabo-wikia committed Mar 11, 2024
1 parent f16f15c commit 0496417
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions includes/CargoFieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0496417

Please sign in to comment.