X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=928066b005bc3e2b5d00a895aef78adf50685568;hb=3301e78e5a2e5662952c0564f830a492743f9844;hp=421cd90ac012f69961de92730c87e7c988f5bd11;hpb=a8181b4a8e009b7f7ee2443179919ba21d217356;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 421cd90ac0..928066b005 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -26,6 +26,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { use Liuggio\StatsdClient\Sender\SocketSender; use MediaWiki\Logger\LoggerFactory; +use MediaWiki\Session\SessionManager; // Hide compatibility functions from Doxygen /// @cond @@ -374,20 +375,22 @@ function wfObjectToArray( $objOrArray, $recursive = true ) { * not likely to give duplicate values for any realistic * number of articles. * + * @note This is designed for use in relation to Special:RandomPage + * and the page_random database field. + * * @return string */ function wfRandom() { - # The maximum random value is "only" 2^31-1, so get two random - # values to reduce the chance of dupes + // The maximum random value is "only" 2^31-1, so get two random + // values to reduce the chance of dupes $max = mt_getrandmax() + 1; $rand = number_format( ( mt_rand() * $max + mt_rand() ) / $max / $max, 12, '.', '' ); - return $rand; } /** - * Get a random string containing a number of pseudo-random hex - * characters. + * Get a random string containing a number of pseudo-random hex characters. + * * @note This is not secure, if you are trying to generate some sort * of token please use MWCryptRand instead. * @@ -458,12 +461,12 @@ function wfUrlencode( $s ) { } /** - * This function takes two arrays as input, and returns a CGI-style string, e.g. + * This function takes one or two arrays as input, and returns a CGI-style string, e.g. * "days=7&limit=100". Options in the first array override options in the second. * Options set to null or false will not be output. * * @param array $array1 ( String|Array ) - * @param array $array2 ( String|Array ) + * @param array|null $array2 ( String|Array ) * @param string $prefix * @return string */ @@ -1036,7 +1039,12 @@ function wfMatchesDomainList( $url, $domains ) { * @since 1.25 support for additional context data * * @param string $text - * @param string|bool $dest Unused + * @param string|bool $dest Destination of the message: + * - 'all': both to the log and HTML (debug toolbar or HTML comments) + * - 'private': excluded from HTML output + * For backward compatibility, it can also take a boolean: + * - true: same as 'all' + * - false: same as 'private' * @param array $context Additional logging context data */ function wfDebug( $text, $dest = 'all', array $context = array() ) { @@ -1049,7 +1057,6 @@ function wfDebug( $text, $dest = 'all', array $context = array() ) { $text = trim( $text ); - // Inline logic from deprecated wfDebugTimer() if ( $wgDebugTimestamps ) { $context['seconds_elapsed'] = sprintf( '%6.4f', @@ -1064,6 +1071,7 @@ function wfDebug( $text, $dest = 'all', array $context = array() ) { if ( $wgDebugLogPrefix !== '' ) { $context['prefix'] = $wgDebugLogPrefix; } + $context['private'] = ( $dest === false || $dest === 'private' ); $logger = LoggerFactory::getInstance( 'wfDebug' ); $logger->debug( $text, $context ); @@ -1092,26 +1100,6 @@ function wfIsDebugRawPage() { return $cache; } -/** - * Get microsecond timestamps for debug logs - * - * @deprecated since 1.25 - * @return string - */ -function wfDebugTimer() { - global $wgDebugTimestamps, $wgRequestTime; - - wfDeprecated( __METHOD__, '1.25' ); - - if ( !$wgDebugTimestamps ) { - return ''; - } - - $prefix = sprintf( "%6.4f", microtime( true ) - $wgRequestTime ); - $mem = sprintf( "%5.1fM", ( memory_get_usage( true ) / ( 1024 * 1024 ) ) ); - return "$prefix $mem "; -} - /** * Send a line giving PHP memory usage. * @@ -1145,7 +1133,6 @@ function wfDebugMem( $exact = false ) { * @param string $text * @param string|bool $dest Destination of the message: * - 'all': both to the log and HTML (debug toolbar or HTML comments) - * - 'log': only to the log and not in HTML * - 'private': only to the specific log if set in $wgDebugLogGroups and * discarded otherwise * For backward compatibility, it can also take a boolean: @@ -1156,17 +1143,10 @@ function wfDebugMem( $exact = false ) { function wfDebugLog( $logGroup, $text, $dest = 'all', array $context = array() ) { - // Turn $dest into a string if it's a boolean (for b/c) - if ( $dest === true ) { - $dest = 'all'; - } elseif ( $dest === false ) { - $dest = 'private'; - } - $text = trim( $text ); $logger = LoggerFactory::getInstance( $logGroup ); - $context['private'] = ( $dest === 'private' ); + $context['private'] = ( $dest === false || $dest === 'private' ); $logger->info( $text, $context ); } @@ -1238,7 +1218,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' ); @@ -1481,159 +1461,6 @@ function wfMessageFallback( /*...*/ ) { return call_user_func_array( 'Message::newFallbackSequence', $args ); } -/** - * Get a message from anywhere, for the current user language. - * - * Use wfMsgForContent() instead if the message should NOT - * change depending on the user preferences. - * - * @deprecated since 1.18 - * - * @param string $key Lookup key for the message, usually - * defined in languages/Language.php - * - * Parameters to the message, which can be used to insert variable text into - * it, can be passed to this function in the following formats: - * - One per argument, starting at the second parameter - * - As an array in the second parameter - * These are not shown in the function definition. - * - * @return string - */ -function wfMsg( $key ) { - wfDeprecated( __METHOD__, '1.21' ); - - $args = func_get_args(); - array_shift( $args ); - return wfMsgReal( $key, $args ); -} - -/** - * Same as above except doesn't transform the message - * - * @deprecated since 1.18 - * - * @param string $key - * @return string - */ -function wfMsgNoTrans( $key ) { - wfDeprecated( __METHOD__, '1.21' ); - - $args = func_get_args(); - array_shift( $args ); - return wfMsgReal( $key, $args, true, false, false ); -} - -/** - * Get a message from anywhere, for the current global language - * set with $wgLanguageCode. - * - * Use this if the message should NOT change dependent on the - * language set in the user's preferences. This is the case for - * most text written into logs, as well as link targets (such as - * the name of the copyright policy page). Link titles, on the - * other hand, should be shown in the UI language. - * - * Note that MediaWiki allows users to change the user interface - * language in their preferences, but a single installation - * typically only contains content in one language. - * - * Be wary of this distinction: If you use wfMsg() where you should - * use wfMsgForContent(), a user of the software may have to - * customize potentially hundreds of messages in - * order to, e.g., fix a link in every possible language. - * - * @deprecated since 1.18 - * - * @param string $key Lookup key for the message, usually - * defined in languages/Language.php - * @return string - */ -function wfMsgForContent( $key ) { - wfDeprecated( __METHOD__, '1.21' ); - - global $wgForceUIMsgAsContentMsg; - $args = func_get_args(); - array_shift( $args ); - $forcontent = true; - if ( is_array( $wgForceUIMsgAsContentMsg ) - && in_array( $key, $wgForceUIMsgAsContentMsg ) - ) { - $forcontent = false; - } - return wfMsgReal( $key, $args, true, $forcontent ); -} - -/** - * Same as above except doesn't transform the message - * - * @deprecated since 1.18 - * - * @param string $key - * @return string - */ -function wfMsgForContentNoTrans( $key ) { - wfDeprecated( __METHOD__, '1.21' ); - - global $wgForceUIMsgAsContentMsg; - $args = func_get_args(); - array_shift( $args ); - $forcontent = true; - if ( is_array( $wgForceUIMsgAsContentMsg ) - && in_array( $key, $wgForceUIMsgAsContentMsg ) - ) { - $forcontent = false; - } - return wfMsgReal( $key, $args, true, $forcontent, false ); -} - -/** - * Really get a message - * - * @deprecated since 1.18 - * - * @param string $key Key to get. - * @param array $args - * @param bool $useDB - * @param string|bool $forContent Language code, or false for user lang, true for content lang. - * @param bool $transform Whether or not to transform the message. - * @return string The requested message. - */ -function wfMsgReal( $key, $args, $useDB = true, $forContent = false, $transform = true ) { - wfDeprecated( __METHOD__, '1.21' ); - - $message = wfMsgGetKey( $key, $useDB, $forContent, $transform ); - $message = wfMsgReplaceArgs( $message, $args ); - return $message; -} - -/** - * Fetch a message string value, but don't replace any keys yet. - * - * @deprecated since 1.18 - * - * @param string $key - * @param bool $useDB - * @param string|bool $langCode Code of the language to get the message for, or - * behaves as a content language switch if it is a boolean. - * @param bool $transform Whether to parse magic words, etc. - * @return string - */ -function wfMsgGetKey( $key, $useDB = true, $langCode = false, $transform = true ) { - wfDeprecated( __METHOD__, '1.21' ); - - Hooks::run( 'NormalizeMessageKey', array( &$key, &$useDB, &$langCode, &$transform ) ); - - $cache = MessageCache::singleton(); - $message = $cache->get( $key, $useDB, $langCode ); - if ( $message === false ) { - $message = '<' . htmlspecialchars( $key ) . '>'; - } elseif ( $transform ) { - $message = $cache->transform( $message ); - } - return $message; -} - /** * Replace message parameter keys on the given formatted output. * @@ -1662,159 +1489,6 @@ function wfMsgReplaceArgs( $message, $args ) { return $message; } -/** - * Return an HTML-escaped version of a message. - * Parameter replacements, if any, are done *after* the HTML-escaping, - * so parameters may contain HTML (eg links or form controls). Be sure - * to pre-escape them if you really do want plaintext, or just wrap - * the whole thing in htmlspecialchars(). - * - * @deprecated since 1.18 - * - * @param string $key - * @param string $args,... Parameters - * @return string - */ -function wfMsgHtml( $key ) { - wfDeprecated( __METHOD__, '1.21' ); - - $args = func_get_args(); - array_shift( $args ); - return wfMsgReplaceArgs( htmlspecialchars( wfMsgGetKey( $key ) ), $args ); -} - -/** - * Return an HTML version of message - * Parameter replacements, if any, are done *after* parsing the wiki-text message, - * so parameters may contain HTML (eg links or form controls). Be sure - * to pre-escape them if you really do want plaintext, or just wrap - * the whole thing in htmlspecialchars(). - * - * @deprecated since 1.18 - * - * @param string $key - * @param string $args,... Parameters - * @return string - */ -function wfMsgWikiHtml( $key ) { - wfDeprecated( __METHOD__, '1.21' ); - - $args = func_get_args(); - array_shift( $args ); - return wfMsgReplaceArgs( - MessageCache::singleton()->parse( wfMsgGetKey( $key ), null, - /* can't be set to false */ true, /* interface */ true )->getText(), - $args ); -} - -/** - * Returns message in the requested format - * - * @deprecated since 1.18 - * - * @param string $key Key of the message - * @param array $options Processing rules. - * Can take the following options: - * parse: parses wikitext to HTML - * parseinline: parses wikitext to HTML and removes the surrounding - * p's added by parser or tidy - * escape: filters message through htmlspecialchars - * escapenoentities: same, but allows entity references like   through - * replaceafter: parameters are substituted after parsing or escaping - * parsemag: transform the message using magic phrases - * content: fetch message for content language instead of interface - * Also can accept a single associative argument, of the form 'language' => 'xx': - * language: Language object or language code to fetch message for - * (overridden by content). - * Behavior for conflicting options (e.g., parse+parseinline) is undefined. - * - * @return string - */ -function wfMsgExt( $key, $options ) { - wfDeprecated( __METHOD__, '1.21' ); - - $args = func_get_args(); - array_shift( $args ); - array_shift( $args ); - $options = (array)$options; - $validOptions = array( 'parse', 'parseinline', 'escape', 'escapenoentities', 'replaceafter', - 'parsemag', 'content' ); - - foreach ( $options as $arrayKey => $option ) { - if ( !preg_match( '/^[0-9]+|language$/', $arrayKey ) ) { - // An unknown index, neither numeric nor "language" - wfWarn( "wfMsgExt called with incorrect parameter key $arrayKey", 1, E_USER_WARNING ); - } elseif ( preg_match( '/^[0-9]+$/', $arrayKey ) && !in_array( $option, $validOptions ) ) { - // A numeric index with unknown value - wfWarn( "wfMsgExt called with incorrect parameter $option", 1, E_USER_WARNING ); - } - } - - if ( in_array( 'content', $options, true ) ) { - $forContent = true; - $langCode = true; - $langCodeObj = null; - } elseif ( array_key_exists( 'language', $options ) ) { - $forContent = false; - $langCode = wfGetLangObj( $options['language'] ); - $langCodeObj = $langCode; - } else { - $forContent = false; - $langCode = false; - $langCodeObj = null; - } - - $string = wfMsgGetKey( $key, /*DB*/true, $langCode, /*Transform*/false ); - - if ( !in_array( 'replaceafter', $options, true ) ) { - $string = wfMsgReplaceArgs( $string, $args ); - } - - $messageCache = MessageCache::singleton(); - $parseInline = in_array( 'parseinline', $options, true ); - if ( in_array( 'parse', $options, true ) || $parseInline ) { - $string = $messageCache->parse( $string, null, true, !$forContent, $langCodeObj ); - if ( $string instanceof ParserOutput ) { - $string = $string->getText(); - } - - if ( $parseInline ) { - $string = Parser::stripOuterParagraph( $string ); - } - } elseif ( in_array( 'parsemag', $options, true ) ) { - $string = $messageCache->transform( $string, - !$forContent, $langCodeObj ); - } - - if ( in_array( 'escape', $options, true ) ) { - $string = htmlspecialchars( $string ); - } elseif ( in_array( 'escapenoentities', $options, true ) ) { - $string = Sanitizer::escapeHtmlAllowEntities( $string ); - } - - if ( in_array( 'replaceafter', $options, true ) ) { - $string = wfMsgReplaceArgs( $string, $args ); - } - - return $string; -} - -/** - * Since wfMsg() and co suck, they don't return false if the message key they - * looked up didn't exist but instead the key wrapped in <>'s, this function checks for the - * nonexistence of messages by checking the MessageCache::get() result directly. - * - * @deprecated since 1.18. Use Message::isDisabled(). - * - * @param string $key The message key looked up - * @return bool True if the message *doesn't* exist. - */ -function wfEmptyMsg( $key ) { - wfDeprecated( __METHOD__, '1.21' ); - - return MessageCache::singleton()->get( $key, /*useDB*/true, /*content*/false ) === false; -} - /** * Fetch server name for use in error reporting etc. * Use real server name if available, so we know which machine @@ -2033,21 +1707,6 @@ function wfClientAcceptsGzip( $force = false ) { return $result; } -/** - * Obtain the offset and limit values from the request string; - * used in special pages - * - * @param int $deflimit Default limit if none supplied - * @param string $optionname Name of a user preference to check against - * @return array - * @deprecated since 1.24, just call WebRequest::getLimitOffset() directly - */ -function wfCheckLimits( $deflimit = 50, $optionname = 'rclimit' ) { - global $wgRequest; - wfDeprecated( __METHOD__, '1.24' ); - return $wgRequest->getLimitOffset( $deflimit, $optionname ); -} - /** * Escapes the given text so that it may be output using addWikiText() * without any linking, formatting, etc. making its way through. This @@ -2503,8 +2162,8 @@ function wfIsHHVM() { /** * Tries to get the system directory for temporary files. First * $wgTmpDirectory is checked, and then the TMPDIR, TMP, and TEMP - * environment variables are then checked in sequence, and if none are - * set try sys_get_temp_dir(). + * environment variables are then checked in sequence, then + * sys_get_temp_dir(), then upload_tmp_dir from php.ini. * * NOTE: When possible, use instead the tmpfile() function to create * temporary files to avoid race conditions on file creation, etc. @@ -2519,13 +2178,16 @@ function wfTempDir() { } $tmpDir = array_map( "getenv", array( 'TMPDIR', 'TMP', 'TEMP' ) ); + $tmpDir[] = sys_get_temp_dir(); + $tmpDir[] = ini_get( 'upload_tmp_dir' ); foreach ( $tmpDir as $tmp ) { if ( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) { return $tmp; } } - return sys_get_temp_dir(); + throw new MWException( 'No writable temporary directory could be found. ' . + 'Please set $wgTmpDirectory to a writable directory.' ); } /** @@ -3330,6 +2992,8 @@ function wfRelativePath( $path, $from ) { * Supports base 2 through 36; digit values 10-36 are represented * as lowercase letters a-z. Input is case-insensitive. * + * @deprecated 1.27 Use Wikimedia\base_convert() directly + * * @param string $input Input number * @param int $sourceBase Base of the input number * @param int $destBase Desired base of the output @@ -3347,9 +3011,12 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, /** * Check if there is sufficient entropy in php's built-in session generation * + * @deprecated since 1.27, PHP's session generation isn't used with + * MediaWiki\\Session\\SessionManager * @return bool True = there is sufficient entropy */ function wfCheckEntropy() { + wfDeprecated( __FUNCTION__, '1.27' ); return ( ( wfIsWindows() && version_compare( PHP_VERSION, '5.3.3', '>=' ) ) || ini_get( 'session.entropy_file' ) @@ -3358,83 +3025,65 @@ function wfCheckEntropy() { } /** - * Override session_id before session startup if php's built-in - * session generation code is not secure. + * @deprecated since 1.27, PHP's session generation isn't used with + * MediaWiki\\Session\\SessionManager */ function wfFixSessionID() { - // If the cookie or session id is already set we already have a session and should abort - if ( isset( $_COOKIE[session_name()] ) || session_id() ) { - return; - } - - // PHP's built-in session entropy is enabled if: - // - entropy_file is set or you're on Windows with php 5.3.3+ - // - AND entropy_length is > 0 - // We treat it as disabled if it doesn't have an entropy length of at least 32 - $entropyEnabled = wfCheckEntropy(); - - // If built-in entropy is not enabled or not sufficient override PHP's - // built in session id generation code - if ( !$entropyEnabled ) { - wfDebug( __METHOD__ . ": PHP's built in entropy is disabled or not sufficient, " . - "overriding session id generation using our cryptrand source.\n" ); - session_id( MWCryptRand::generateHex( 32 ) ); - } + wfDeprecated( __FUNCTION__, '1.27' ); } /** - * Reset the session_id + * Reset the session id * + * @deprecated since 1.27, use MediaWiki\\Session\\SessionManager instead * @since 1.22 */ function wfResetSessionID() { - global $wgCookieSecure; - $oldSessionId = session_id(); - $cookieParams = session_get_cookie_params(); - if ( wfCheckEntropy() && $wgCookieSecure == $cookieParams['secure'] ) { - session_regenerate_id( false ); - } else { - $tmp = $_SESSION; - session_destroy(); - wfSetupSession( MWCryptRand::generateHex( 32 ) ); - $_SESSION = $tmp; + wfDeprecated( __FUNCTION__, '1.27' ); + $session = SessionManager::getGlobalSession(); + $delay = $session->delaySave(); + + $session->resetId(); + + // Make sure a session is started, since that's what the old + // wfResetSessionID() did. + if ( session_id() !== $session->getId() ) { + wfSetupSession( $session->getId() ); } - $newSessionId = session_id(); + + ScopedCallback::consume( $delay ); } /** * Initialise php session * - * @param bool $sessionId + * @deprecated since 1.27, use MediaWiki\\Session\\SessionManager instead. + * Generally, "using" SessionManager will be calling ->getSessionById() or + * ::getGlobalSession() (depending on whether you were passing $sessionId + * here), then calling $session->persist(). + * @param bool|string $sessionId */ function wfSetupSession( $sessionId = false ) { - global $wgSessionsInObjectCache, $wgSessionHandler; - global $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly; + wfDeprecated( __FUNCTION__, '1.27' ); - if ( $wgSessionsInObjectCache ) { - ObjectCacheSessionHandler::install(); - } elseif ( $wgSessionHandler && $wgSessionHandler != ini_get( 'session.save_handler' ) ) { - # Only set this if $wgSessionHandler isn't null and session.save_handler - # hasn't already been set to the desired value (that causes errors) - ini_set( 'session.save_handler', $wgSessionHandler ); + // If they're calling this, they probably want our session management even + // if NO_SESSION was set for Setup.php. + if ( !MediaWiki\Session\PHPSessionHandler::isInstalled() ) { + MediaWiki\Session\PHPSessionHandler::install( SessionManager::singleton() ); } - session_set_cookie_params( - 0, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly ); - session_cache_limiter( 'private, must-revalidate' ); if ( $sessionId ) { session_id( $sessionId ); - } else { - wfFixSessionID(); } - MediaWiki\suppressWarnings(); - session_start(); - MediaWiki\restoreWarnings(); + $session = SessionManager::getGlobalSession(); + $session->persist(); - if ( $wgSessionsInObjectCache ) { - ObjectCacheSessionHandler::renewCurrentSession(); + if ( session_id() !== $session->getId() ) { + session_id( $session->getId() ); } + + MediaWiki\quietCall( 'session_start' ); } /** @@ -3700,55 +3349,35 @@ function wfGetNull() { * @param string|bool $cluster Cluster name accepted by LBFactory. Default: false. * @param int|null $timeout Max wait time. Default: 1 day (cli), ~10 seconds (web) * @return bool Success (able to connect and no timeouts reached) + * @deprecated since 1.27 Use LBFactory::waitForReplication */ function wfWaitForSlaves( $ifWritesSince = null, $wiki = false, $cluster = false, $timeout = null ) { - // B/C: first argument used to be "max seconds of lag"; ignore such values - $ifWritesSince = ( $ifWritesSince > 1e9 ) ? $ifWritesSince : null; - if ( $timeout === null ) { $timeout = ( PHP_SAPI === 'cli' ) ? 86400 : 10; } - // Figure out which clusters need to be checked - /** @var LoadBalancer[] $lbs */ - $lbs = array(); if ( $cluster === '*' ) { - wfGetLBFactory()->forEachLB( function ( LoadBalancer $lb ) use ( &$lbs ) { - $lbs[] = $lb; - } ); - } elseif ( $cluster !== false ) { - $lbs[] = wfGetLBFactory()->getExternalLB( $cluster ); - } else { - $lbs[] = wfGetLB( $wiki ); - } - - // Get all the master positions of applicable DBs right now. - // This can be faster since waiting on one cluster reduces the - // time needed to wait on the next clusters. - $masterPositions = array_fill( 0, count( $lbs ), false ); - foreach ( $lbs as $i => $lb ) { - if ( $lb->getServerCount() <= 1 ) { - // Bug 27975 - Don't try to wait for slaves if there are none - // Prevents permission error when getting master position - continue; - } elseif ( $ifWritesSince && $lb->lastMasterChangeTimestamp() < $ifWritesSince ) { - continue; // no writes since the last wait - } - $masterPositions[$i] = $lb->getMasterPos(); + $cluster = false; + $wiki = false; + } elseif ( $wiki === false ) { + $wiki = wfWikiID(); } - $ok = true; - foreach ( $lbs as $i => $lb ) { - if ( $masterPositions[$i] ) { - // The DBMS may not support getMasterPos() or the whole - // load balancer might be fake (e.g. $wgAllDBsAreLocalhost). - $ok = $lb->waitForAll( $masterPositions[$i], $timeout ) && $ok; - } + try { + wfGetLBFactory()->waitForReplication( array( + 'wiki' => $wiki, + 'cluster' => $cluster, + 'timeout' => $timeout, + // B/C: first argument used to be "max seconds of lag"; ignore such values + 'ifWritesSince' => ( $ifWritesSince > 1e9 ) ? $ifWritesSince : null + ) ); + } catch ( DBReplicationWaitError $e ) { + return false; } - return $ok; + return true; } /** @@ -4089,46 +3718,6 @@ function wfIsInfinity( $str ) { return in_array( $str, $infinityValues ); } -/** - * Work out the IP address based on various globals - * For trusted proxies, use the XFF client IP (first of the chain) - * - * @deprecated since 1.19; call $wgRequest->getIP() directly. - * @return string - */ -function wfGetIP() { - wfDeprecated( __METHOD__, '1.19' ); - global $wgRequest; - return $wgRequest->getIP(); -} - -/** - * Checks if an IP is a trusted proxy provider. - * Useful to tell if X-Forwarded-For data is possibly bogus. - * Squid cache servers for the site are whitelisted. - * @deprecated Since 1.24, use IP::isTrustedProxy() - * - * @param string $ip - * @return bool - */ -function wfIsTrustedProxy( $ip ) { - wfDeprecated( __METHOD__, '1.24' ); - return IP::isTrustedProxy( $ip ); -} - -/** - * Checks if an IP matches a proxy we've configured. - * @deprecated Since 1.24, use IP::isConfiguredProxy() - * - * @param string $ip - * @return bool - * @since 1.23 Supports CIDR ranges in $wgSquidServersNoPurge - */ -function wfIsConfiguredProxy( $ip ) { - wfDeprecated( __METHOD__, '1.24' ); - return IP::isConfiguredProxy( $ip ); -} - /** * Returns true if these thumbnail parameters match one that MediaWiki * requests from file description pages and/or parser output.