From: Kevin Israel Date: Wed, 13 May 2015 07:36:43 +0000 (-0400) Subject: wfBaseConvert(): Avoid PHP warning when converting zero X-Git-Tag: 1.31.0-rc.0~11420 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=cfaaff106862e84bb15e4bc21acd43843715cb2f;p=lhc%2Fweb%2Fwiklou.git wfBaseConvert(): Avoid PHP warning when converting zero The warning occurs when gmp_init() tries to convert the empty string that came from ltrim(). This is causing tests to fail under HHVM 3.6.1. Follows-up 5957856c46c3. Bug: T98882 Change-Id: Ica86c91d7897db979e09d7cfc82fb3a20b95d4ce --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 6eaeb25afd..8b3b959a36 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3353,7 +3353,7 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, // Removing leading zeros works around broken base detection code in // some PHP versions (see and // ). - $result = gmp_strval( gmp_init( ltrim( $input, '0' ), $sourceBase ), $destBase ); + $result = gmp_strval( gmp_init( ltrim( $input, '0' ) ?: '0', $sourceBase ), $destBase ); } elseif ( extension_loaded( 'bcmath' ) && ( $engine == 'auto' || $engine == 'bcmath' ) ) { $decimal = '0'; foreach ( str_split( strtolower( $input ) ) as $char ) {