X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=125b917caad71ec305b2433918778ed8a90c1a07;hb=f4a5de374068b712992d8ca273c5db15b8041dd0;hp=2cde17323617af21de431311d87b11b6cd09339f;hpb=35243c574fa96b447d1683a9cae234ec7958d611;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 2cde173236..125b917caa 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -518,7 +518,7 @@ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) { } } - $defaultProtoWithoutSlashes = substr( $defaultProto, 0, -2 ); + $defaultProtoWithoutSlashes = $defaultProto !== null ? substr( $defaultProto, 0, -2 ) : ''; if ( substr( $url, 0, 2 ) == '//' ) { $url = $defaultProtoWithoutSlashes . $url; @@ -1816,10 +1816,11 @@ function mimeTypeMatch( $type, $avail ) { * * @param array $cprefs Client's acceptable type list * @param array $sprefs Server's offered types - * @return string + * @return string|null * * @todo FIXME: Doesn't handle params like 'text/plain; charset=UTF-8' * XXX: generalize to negotiate other stuff + * @todo The function appears unused. Is it worth to keep? */ function wfNegotiateType( $cprefs, $sprefs ) { $combine = []; @@ -2030,7 +2031,7 @@ function wfRecursiveRemoveDir( $dir ) { */ function wfPercent( $nr, $acc = 2, $round = true ) { $ret = sprintf( "%.${acc}f", $nr ); - return $round ? round( $ret, $acc ) . '%' : "$ret%"; + return $round ? round( (float)$ret, $acc ) . '%' : "$ret%"; } /** @@ -2135,7 +2136,6 @@ function wfShellExec( $cmd, &$retval = null, $environ = [], } $includeStderr = isset( $options['duplicateStderr'] ) && $options['duplicateStderr']; - // @phan-suppress-next-line PhanTypeInvalidDimOffset $profileMethod = $options['profileMethod'] ?? wfGetCaller(); try { @@ -2200,7 +2200,6 @@ function wfShellWikiCmd( $script, array $parameters = [], array $options = [] ) // Give site config file a chance to run the script in a wrapper. // The caller may likely want to call wfBasename() on $script. Hooks::run( 'wfShellWikiCmd', [ &$script, &$parameters, &$options ] ); - // @phan-suppress-next-line PhanTypeInvalidDimOffset $cmd = [ $options['php'] ?? $wgPhpCli ]; if ( isset( $options['wrapper'] ) ) { $cmd[] = $options['wrapper']; @@ -2795,7 +2794,7 @@ function wfMemoryLimit( $newLimit ) { function wfTransactionalTimeLimit() { global $wgTransactionalTimeLimit; - $timeLimit = ini_get( 'max_execution_time' ); + $timeLimit = (int)ini_get( 'max_execution_time' ); // Note that CLI scripts use 0 if ( $timeLimit > 0 && $wgTransactionalTimeLimit > $timeLimit ) { set_time_limit( $wgTransactionalTimeLimit ); @@ -2897,7 +2896,6 @@ function wfUnpack( $format, $data, $length = false ) { $result = unpack( $format, $data ); Wikimedia\restoreWarnings(); - // @phan-suppress-next-line PhanTypeComparisonFromArray Phan issue #3160 if ( $result === false ) { // If it cannot extract the packed data. throw new MWException( "unpack could not unpack binary data" );