X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=4f121107e2977f412aeaaa785229560fc02cfcb8;hb=65f714e1e679127c4d38a40e7b23da8cee2195d6;hp=4a09b9c6a1adf61af8c959e72f7d64e2399d7c32;hpb=fb1b454e6a6fb5cf4df40ce9cfa329f207ff0a10;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 4a09b9c6a1..4f121107e2 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -30,7 +30,6 @@ use MediaWiki\Session\SessionManager; use MediaWiki\MediaWikiServices; use MediaWiki\Shell\Shell; use Wikimedia\ScopedCallback; -use Wikimedia\Rdbms\DBReplicationWaitError; use Wikimedia\WrappedString; /** @@ -1308,11 +1307,11 @@ function wfGetLangObj( $langcode = false ) { return $langcode; } - global $wgContLang, $wgLanguageCode; + global $wgLanguageCode; if ( $langcode === true || $langcode === $wgLanguageCode ) { # $langcode is the language code of the wikis content language object. # or it is a boolean and value is true - return $wgContLang; + return MediaWikiServices::getInstance()->getContentLanguage(); } global $wgLang; @@ -1330,7 +1329,7 @@ function wfGetLangObj( $langcode = false ) { # $langcode is a string, but not a valid language code; use content language. wfDebug( "Invalid language code passed to wfGetLangObj, falling back to content language.\n" ); - return $wgContLang; + return MediaWikiServices::getInstance()->getContentLanguage(); } /** @@ -2674,28 +2673,6 @@ function wfGetPrecompiledData( $name ) { return false; } -/** - * @since 1.32 - * @param string[] $data Array with string keys/values to export - * @param string $header - * @return string PHP code - */ -function wfMakeStaticArrayFile( array $data, $header = 'Automatically generated' ) { - $format = "\t%s => %s,\n"; - $code = " $value ) { - $code .= sprintf( - $format, - var_export( $key, true ), - var_export( $value, true ) - ); - } - $code .= "];\n"; - return $code; -} - /** * Make a cache key for the local wiki. * @@ -2944,17 +2921,13 @@ function wfGetNull() { * @param float|null $ifWritesSince Only wait if writes were done since this UNIX timestamp * @param string|bool $wiki Wiki identifier accepted by wfGetLB * @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) + * @param int|null $timeout Max wait time. Default: 60 seconds (cli), 1 second (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 ) { - if ( $timeout === null ) { - $timeout = wfIsCLI() ? 60 : 10; - } - if ( $cluster === '*' ) { $cluster = false; $wiki = false; @@ -2962,20 +2935,18 @@ function wfWaitForSlaves( $wiki = wfWikiID(); } - try { - $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); - $lbFactory->waitForReplication( [ - '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; + $opts = [ + 'wiki' => $wiki, + 'cluster' => $cluster, + // B/C: first argument used to be "max seconds of lag"; ignore such values + 'ifWritesSince' => ( $ifWritesSince > 1e9 ) ? $ifWritesSince : null + ]; + if ( $timeout !== null ) { + $opts['timeout'] = $timeout; } - return true; + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + return $lbFactory->waitForReplication( $opts ); } /** @@ -3119,6 +3090,7 @@ function wfBCP47( $code ) { /** * Get a specific cache object. * + * @deprecated since 1.32, use ObjectCache::getInstance() instead * @param int|string $cacheType A CACHE_* constants, or other key in $wgObjectCaches * @return BagOStuff */ @@ -3129,11 +3101,11 @@ function wfGetCache( $cacheType ) { /** * Get the main cache object * + * @deprecated since 1.32, use ObjectCache::getLocalClusterInstance() instead * @return BagOStuff */ function wfGetMainCache() { - global $wgMainCacheType; - return ObjectCache::getInstance( $wgMainCacheType ); + return ObjectCache::getLocalClusterInstance(); } /**