X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=4531b5401b0704ecf01d6983ecb75b4381e5aec3;hb=cc7ac561d5efc4b2bbd8c9fef49e84898d5486bb;hp=336cb89e99ae02c266384a99b8c8f4bc9e9bb557;hpb=7c4b637cca308651cb98d40b2bd7dca187160e81;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 336cb89e99..4531b5401b 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -197,11 +197,10 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) { * [ 'y' ] * ] * - * @param array $array1,... + * @param array ...$args * @return array */ -function wfMergeErrorArrays( /*...*/ ) { - $args = func_get_args(); +function wfMergeErrorArrays( ...$args ) { $out = []; foreach ( $args as $errors ) { foreach ( $errors as $params ) { @@ -1147,26 +1146,6 @@ function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) { MWDebug::warning( $msg, $callerOffset + 1, $level, 'production' ); } -/** - * Log to a file without getting "file size exceeded" signals. - * - * Can also log to TCP or UDP with the syntax udp://host:port/prefix. This will - * send lines to the specified port, prefixed by the specified prefix and a space. - * @since 1.25 support for additional context data - * - * @param string $text - * @param string $file Filename - * @param array $context Additional logging context data - * @throws MWException - * @deprecated since 1.25 Use \MediaWiki\Logger\LegacyLogger::emit or UDPTransport - */ -function wfErrorLog( $text, $file, array $context = [] ) { - wfDeprecated( __METHOD__, '1.25' ); - $logger = LoggerFactory::getInstance( 'wfErrorLog' ); - $context['destination'] = $file; - $logger->info( trim( $text ), $context ); -} - /** * @todo document * @todo Move logic to MediaWiki.php @@ -2196,13 +2175,13 @@ function wfStringToBool( $val ) { * (https://bugs.php.net/bug.php?id=26285) and the locale problems on Linux in * PHP 5.2.6+ (bug backported to earlier distro releases of PHP). * - * @param string $args,... strings to escape and glue together, + * @param string|string[] ...$args strings to escape and glue together, * or a single array of strings parameter * @return string * @deprecated since 1.30 use MediaWiki\Shell::escape() */ -function wfEscapeShellArg( /*...*/ ) { - return Shell::escape( ...func_get_args() ); +function wfEscapeShellArg( ...$args ) { + return Shell::escape( ...$args ); } /** @@ -2476,33 +2455,6 @@ function wfDiff( $before, $after, $params = '-u' ) { return $diff; } -/** - * This function works like "use VERSION" in Perl, the program will die with a - * backtrace if the current version of PHP is less than the version provided - * - * This is useful for extensions which due to their nature are not kept in sync - * with releases, and might depend on other versions of PHP than the main code - * - * Note: PHP might die due to parsing errors in some cases before it ever - * manages to call this function, such is life - * - * @see perldoc -f use - * - * @param string|int|float $req_ver The version to check, can be a string, an integer, or a float - * - * @deprecated since 1.30 - * - * @throws MWException - */ -function wfUsePHP( $req_ver ) { - wfDeprecated( __FUNCTION__, '1.30' ); - $php_ver = PHP_VERSION; - - if ( version_compare( $php_ver, (string)$req_ver, '<' ) ) { - throw new MWException( "PHP $req_ver required--this is only $php_ver" ); - } -} - /** * Return the final portion of a pathname. * Reimplemented because PHP5's "basename()" is buggy with multibyte text. @@ -2645,11 +2597,11 @@ function wfGetPrecompiledData( $name ) { * Make a cache key for the local wiki. * * @deprecated since 1.30 Call makeKey on a BagOStuff instance - * @param string $args,... + * @param string ...$args * @return string */ -function wfMemcKey( /*...*/ ) { - return ObjectCache::getLocalClusterInstance()->makeKey( ...func_get_args() ); +function wfMemcKey( ...$args ) { + return ObjectCache::getLocalClusterInstance()->makeKey( ...$args ); } /** @@ -2659,11 +2611,10 @@ function wfMemcKey( /*...*/ ) { * * @param string $db * @param string $prefix - * @param string $args,... + * @param string ...$args * @return string */ -function wfForeignMemcKey( $db, $prefix /*...*/ ) { - $args = array_slice( func_get_args(), 2 ); +function wfForeignMemcKey( $db, $prefix, ...$args ) { $keyspace = $prefix ? "$db-$prefix" : $db; return ObjectCache::getLocalClusterInstance()->makeKeyInternal( $keyspace, $args ); } @@ -2677,11 +2628,11 @@ function wfForeignMemcKey( $db, $prefix /*...*/ ) { * * @deprecated since 1.30 Call makeGlobalKey on a BagOStuff instance * @since 1.26 - * @param string $args,... + * @param string ...$args * @return string */ -function wfGlobalCacheKey( /*...*/ ) { - return ObjectCache::getLocalClusterInstance()->makeGlobalKey( ...func_get_args() ); +function wfGlobalCacheKey( ...$args ) { + return ObjectCache::getLocalClusterInstance()->makeGlobalKey( ...$args ); } /** @@ -2896,15 +2847,19 @@ function wfGetNull() { function wfWaitForSlaves( $ifWritesSince = null, $wiki = false, $cluster = false, $timeout = null ) { + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + if ( $cluster === '*' ) { $cluster = false; - $wiki = false; + $domain = false; } elseif ( $wiki === false ) { - $wiki = wfWikiID(); + $domain = $lbFactory->getLocalDomainID(); + } else { + $domain = $wiki; } $opts = [ - 'wiki' => $wiki, + 'domain' => $domain, 'cluster' => $cluster, // B/C: first argument used to be "max seconds of lag"; ignore such values 'ifWritesSince' => ( $ifWritesSince > 1e9 ) ? $ifWritesSince : null @@ -2913,7 +2868,6 @@ function wfWaitForSlaves( $opts['timeout'] = $timeout; } - $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); return $lbFactory->waitForReplication( $opts ); } @@ -3086,21 +3040,6 @@ function wfGetMessageCacheStorage() { return ObjectCache::getInstance( $wgMessageCacheType ); } -/** - * Call hook functions defined in $wgHooks - * - * @param string $event Event name - * @param array $args Parameters passed to hook functions - * @param string|null $deprecatedVersion Optionally mark hook as deprecated with version number - * - * @return bool True if no handler aborted the hook - * @deprecated since 1.25 - use Hooks::run - */ -function wfRunHooks( $event, array $args = [], $deprecatedVersion = null ) { - wfDeprecated( __METHOD__, '1.25' ); - return Hooks::run( $event, $args, $deprecatedVersion ); -} - /** * Wrapper around php's unpack. *