X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=bb1951d52822759c9664a66ed3182a8481368c6e;hb=7507172e95721c6193d574e461f75dae1ff1d0f0;hp=d53e98dbe1747bcd7f267ab396417e910ae37f97;hpb=aad97651acf1c8a4c1bf667bfd396563ed51977b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d53e98dbe1..bb1951d528 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2225,7 +2225,23 @@ function wfPercent( $nr, $acc = 2, $round = true ) { * @return bool */ function wfIniGetBool( $setting ) { - $val = strtolower( ini_get( $setting ) ); + return wfStringToBool( ini_get( $setting ) ); +} + +/** + * Convert string value to boolean, when the following are interpreted as true: + * - on + * - true + * - yes + * - Any number, except 0 + * All other strings are interpreted as false. + * + * @param string $val + * @return bool + * @since 1.31 + */ +function wfStringToBool( $val ) { + $val = strtolower( $val ); // 'on' and 'true' can't have whitespace around them, but '1' can. return $val == 'on' || $val == 'true' @@ -2684,6 +2700,7 @@ function wfRelativePath( $path, $from ) { function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, $lowercase = true, $engine = 'auto' ) { + wfDeprecated( __FUNCTION__, '1.27' ); return Wikimedia\base_convert( $input, $sourceBase, $destBase, $pad, $lowercase, $engine ); } @@ -3047,6 +3064,8 @@ function wfWaitForSlaves( * Count down from $seconds to zero on the terminal, with a one-second pause * between showing each number. For use in command-line scripts. * + * @deprecated since 1.31, use Maintenance::countDown() + * * @codeCoverageIgnore * @param int $seconds */ @@ -3229,6 +3248,7 @@ function wfGetParserCacheStorage() { * @deprecated since 1.25 - use Hooks::run */ function wfRunHooks( $event, array $args = [], $deprecatedVersion = null ) { + wfDeprecated( __METHOD__, '1.25' ); return Hooks::run( $event, $args, $deprecatedVersion ); } @@ -3483,3 +3503,37 @@ function wfArrayPlus2d( array $baseArray, array $newValues ) { return $baseArray; } + +/** + * Get system resource usage of current request context. + * Invokes the getrusage(2) system call, requesting RUSAGE_SELF if on PHP5 + * or RUSAGE_THREAD if on HHVM. Returns false if getrusage is not available. + * + * @since 1.24 + * @return array|bool Resource usage data or false if no data available. + */ +function wfGetRusage() { + if ( !function_exists( 'getrusage' ) ) { + return false; + } elseif ( defined( 'HHVM_VERSION' ) && PHP_OS === 'Linux' ) { + return getrusage( 2 /* RUSAGE_THREAD */ ); + } else { + return getrusage( 0 /* RUSAGE_SELF */ ); + } +} + +/** + * Begin profiling of a function + * @param string $functionname Name of the function we will profile + * @deprecated since 1.25 + */ +function wfProfileIn( $functionname ) { +} + +/** + * Stop profiling of a function + * @param string $functionname Name of the function we have profiled + * @deprecated since 1.25 + */ +function wfProfileOut( $functionname = 'missing' ) { +}