X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=cda3154253dd3d5dff9546385d73460db59b5dda;hb=52010e6d21d8bdefa1c89fbc9421850185cc5011;hp=c24aaec2c2272a277805a3d4cedca2d637f7358c;hpb=d8816a0801ac577ebebd190815e38bbb85ce221a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c24aaec2c2..cda3154253 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1233,7 +1233,7 @@ function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) { * @param string $file Filename * @param array $context Additional logging context data * @throws MWException - * @deprecated since 1.25 Use MediaWiki\Logger\LegacyLogger::emit or UDPTransport + * @deprecated since 1.25 Use \\MediaWiki\\Logger\\LegacyLogger::emit or UDPTransport */ function wfErrorLog( $text, $file, array $context = array() ) { wfDeprecated( __METHOD__, '1.25' ); @@ -1355,24 +1355,14 @@ function wfReadOnlyReason() { return $readOnly; } - static $autoReadOnly = null; - if ( $autoReadOnly === null ) { + static $lbReadOnly = null; + if ( $lbReadOnly === null ) { // Callers use this method to be aware that data presented to a user // may be very stale and thus allowing submissions can be problematic. - try { - if ( wfGetLB()->getLaggedSlaveMode() ) { - $autoReadOnly = 'The database has been automatically locked ' . - 'while the slave database servers catch up to the master'; - } else { - $autoReadOnly = false; - } - } catch ( DBConnectionError $e ) { - $autoReadOnly = 'The database has been automatically locked ' . - 'until the slave database servers become available'; - } + $lbReadOnly = wfGetLB()->getReadOnlyReason(); } - return $autoReadOnly; + return $lbReadOnly; } /** @@ -1985,8 +1975,11 @@ function wfGetAllCallers( $limit = 3 ) { * @return string */ function wfFormatStackFrame( $frame ) { - return isset( $frame['class'] ) ? - $frame['class'] . '::' . $frame['function'] : + if ( !isset( $frame['function'] ) ) { + return 'NO_FUNCTION_GIVEN'; + } + return isset( $frame['class'] ) && isset( $frame['type'] ) ? + $frame['class'] . $frame['type'] . $frame['function'] : $frame['function']; } @@ -2856,16 +2849,17 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $status = false; $logMsg = false; - // According to the documentation, it is possible for stream_select() - // to fail due to EINTR. I haven't managed to induce this in testing - // despite sending various signals. If it did happen, the error - // message would take the form: - // - // stream_select(): unable to select [4]: Interrupted system call (max_fd=5) - // - // where [4] is the value of the macro EINTR and "Interrupted system - // call" is string which according to the Linux manual is "possibly" - // localised according to LC_MESSAGES. + /* According to the documentation, it is possible for stream_select() + * to fail due to EINTR. I haven't managed to induce this in testing + * despite sending various signals. If it did happen, the error + * message would take the form: + * + * stream_select(): unable to select [4]: Interrupted system call (max_fd=5) + * + * where [4] is the value of the macro EINTR and "Interrupted system + * call" is string which according to the Linux manual is "possibly" + * localised according to LC_MESSAGES. + */ $eintr = defined( 'SOCKET_EINTR' ) ? SOCKET_EINTR : 4; $eintrMessage = "stream_select(): unable to select [$eintr]"; @@ -3554,11 +3548,10 @@ function wfGetPrecompiledData( $name ) { * @return string */ function wfMemcKey( /*...*/ ) { - global $wgCachePrefix; - $prefix = $wgCachePrefix === false ? wfWikiID() : $wgCachePrefix; - $args = func_get_args(); - $key = $prefix . ':' . implode( ':', $args ); - return strtr( $key, ' ', '_' ); + return call_user_func_array( + array( ObjectCache::getLocalClusterInstance(), 'makeKey' ), + func_get_args() + ); } /** @@ -3573,13 +3566,11 @@ function wfMemcKey( /*...*/ ) { */ function wfForeignMemcKey( $db, $prefix /*...*/ ) { $args = array_slice( func_get_args(), 2 ); - if ( $prefix ) { - // Match wfWikiID() logic - $key = "$db-$prefix:" . implode( ':', $args ); - } else { - $key = $db . ':' . implode( ':', $args ); - } - return strtr( $key, ' ', '_' ); + $keyspace = $prefix ? "$db-$prefix" : $db; + return call_user_func_array( + array( ObjectCache::getLocalClusterInstance(), 'makeKeyInternal' ), + array( $keyspace, $args ) + ); } /** @@ -3594,9 +3585,10 @@ function wfForeignMemcKey( $db, $prefix /*...*/ ) { * @return string */ function wfGlobalCacheKey( /*...*/ ) { - $args = func_get_args(); - $key = 'global:' . implode( ':', $args ); - return strtr( $key, ' ', '_' ); + return call_user_func_array( + array( ObjectCache::getLocalClusterInstance(), 'makeGlobalKey' ), + func_get_args() + ); } /** @@ -3737,16 +3729,16 @@ function wfScript( $script = 'index' ) { */ function wfGetScriptUrl() { if ( isset( $_SERVER['SCRIPT_NAME'] ) ) { - # - # as it was called, minus the query string. - # - # Some sites use Apache rewrite rules to handle subdomains, - # and have PHP set up in a weird way that causes PHP_SELF - # to contain the rewritten URL instead of the one that the - # outside world sees. - # - # If in this mode, use SCRIPT_URL instead, which mod_rewrite - # provides containing the "before" URL. + /* as it was called, minus the query string. + * + * Some sites use Apache rewrite rules to handle subdomains, + * and have PHP set up in a weird way that causes PHP_SELF + * to contain the rewritten URL instead of the one that the + * outside world sees. + * + * If in this mode, use SCRIPT_URL instead, which mod_rewrite + * provides containing the "before" URL. + */ return $_SERVER['SCRIPT_NAME']; } else { return $_SERVER['URL']; @@ -3936,12 +3928,13 @@ function wfTransactionalTimeLimit() { * Converts shorthand byte notation to integer form * * @param string $string + * @param int $default Returned if $string is empty * @return int */ -function wfShorthandToInteger( $string = '' ) { +function wfShorthandToInteger( $string = '', $default = -1 ) { $string = trim( $string ); if ( $string === '' ) { - return -1; + return $default; } $last = $string[strlen( $string ) - 1]; $val = intval( $string );