use Liuggio\StatsdClient\Sender\SocketSender;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\Session\SessionManager;
+use MediaWiki\MediaWikiServices;
use Wikimedia\ScopedCallback;
use Wikimedia\Rdbms\DBReplicationWaitError;
$profiler->logData();
$config = $context->getConfig();
- if ( $config->get( 'StatsdServer' ) ) {
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
+ if ( $config->get( 'StatsdServer' ) && $stats->hasData() ) {
try {
$statsdServer = explode( ':', $config->get( 'StatsdServer' ) );
$statsdHost = $statsdServer[0];
$statsdSender = new SocketSender( $statsdHost, $statsdPort );
$statsdClient = new SamplingStatsdClient( $statsdSender, true, false );
$statsdClient->setSamplingRates( $config->get( 'StatsdSamplingRates' ) );
- $statsdClient->send( $context->getStats()->getBuffer() );
+ $statsdClient->send( $stats->getData() );
} catch ( Exception $ex ) {
MWExceptionHandler::logException( $ex );
}
* @return void
*/
function wfIncrStats( $key, $count = 1 ) {
- $stats = RequestContext::getMain()->getStats();
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
$stats->updateCount( $key, $count );
}
* @return bool
*/
function wfReadOnly() {
- return \MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()
+ return MediaWikiServices::getInstance()->getReadOnlyMode()
->isReadOnly();
}
* @return string|bool String when in read-only mode; false otherwise
*/
function wfReadOnlyReason() {
- return \MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()
+ return MediaWikiServices::getInstance()->getReadOnlyMode()
->getReason();
}
* @since 1.27
*/
function wfConfiguredReadOnlyReason() {
- return \MediaWiki\MediaWikiServices::getInstance()->getConfiguredReadOnlyMode()
+ return MediaWikiServices::getInstance()->getConfiguredReadOnlyMode()
->getReason();
}
function wfHostname() {
static $host;
if ( is_null( $host ) ) {
-
# Hostname overriding
global $wgOverrideHostname;
if ( $wgOverrideHostname !== false ) {
}
/**
- * Workaround for https://bugs.php.net/bug.php?id=45132
- * escapeshellarg() destroys non-ASCII characters if LANG is not a UTF-8 locale
+ * Set the locale for locale-sensitive operations
+ *
+ * Sets LC_ALL to a known value to work around issues like the following:
+ * - https://bugs.php.net/bug.php?id=45132 escapeshellarg() destroys non-ASCII
+ * characters if LANG is not a UTF-8 locale
+ * - T107128 Scribunto string comparison works case insensitive while the
+ * standard Lua case sensitive
+ *
+ * @see $wgShellLocale
*/
function wfInitShellLocale() {
static $done = false;
}
$done = true;
global $wgShellLocale;
- putenv( "LC_CTYPE=$wgShellLocale" );
- setlocale( LC_CTYPE, $wgShellLocale );
+ putenv( "LC_ALL=$wgShellLocale" );
+ setlocale( LC_ALL, $wgShellLocale );
}
/**
/**
* Make a cache key for the local wiki.
*
+ * @deprecated since 1.30 Call makeKey on a BagOStuff instance
* @param string $args,...
* @return string
*/
* instead. Must have a prefix as otherwise keys that use a database name
* in the first segment will clash with wfMemcKey/wfForeignMemcKey.
*
+ * @deprecated since 1.30 Call makeGlobalKey on a BagOStuff instance
* @since 1.26
* @param string $args,...
* @return string
*/
function wfGetLB( $wiki = false ) {
if ( $wiki === false ) {
- return \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancer();
+ return MediaWikiServices::getInstance()->getDBLoadBalancer();
} else {
- $factory = \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
return $factory->getMainLB( $wiki );
}
}
* @return \Wikimedia\Rdbms\LBFactory
*/
function wfGetLBFactory() {
- return \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ return MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
}
/**
}
$cache = ObjectCache::getLocalServerInstance( 'hash' );
- $key = wfMemcKey( 'bad-image-list', ( $blacklist === null ) ? 'default' : md5( $blacklist ) );
+ $key = $cache->makeKey(
+ 'bad-image-list', ( $blacklist === null ) ? 'default' : md5( $blacklist )
+ );
$badImages = $cache->get( $key );
if ( $badImages === false ) { // cache miss