wfIsBadImage: Avoid deprecated wfMemcKey()
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 4325328..e1d0520 100644 (file)
@@ -1276,7 +1276,7 @@ function wfIncrStats( $key, $count = 1 ) {
  * @return bool
  */
 function wfReadOnly() {
-       return \MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()
+       return MediaWikiServices::getInstance()->getReadOnlyMode()
                ->isReadOnly();
 }
 
@@ -1289,7 +1289,7 @@ function wfReadOnly() {
  * @return string|bool String when in read-only mode; false otherwise
  */
 function wfReadOnlyReason() {
-       return \MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()
+       return MediaWikiServices::getInstance()->getReadOnlyMode()
                ->getReason();
 }
 
@@ -1300,7 +1300,7 @@ function wfReadOnlyReason() {
  * @since 1.27
  */
 function wfConfiguredReadOnlyReason() {
-       return \MediaWiki\MediaWikiServices::getInstance()->getConfiguredReadOnlyMode()
+       return MediaWikiServices::getInstance()->getConfiguredReadOnlyMode()
                ->getReason();
 }
 
@@ -1436,7 +1436,6 @@ function wfMsgReplaceArgs( $message, $args ) {
 function wfHostname() {
        static $host;
        if ( is_null( $host ) ) {
-
                # Hostname overriding
                global $wgOverrideHostname;
                if ( $wgOverrideHostname !== false ) {
@@ -2535,8 +2534,15 @@ function wfShellExecWithStderr( $cmd, &$retval = null, $environ = [], $limits =
 }
 
 /**
- * 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;
@@ -2545,8 +2551,8 @@ function wfInitShellLocale() {
        }
        $done = true;
        global $wgShellLocale;
-       putenv( "LC_CTYPE=$wgShellLocale" );
-       setlocale( LC_CTYPE, $wgShellLocale );
+       putenv( "LC_ALL=$wgShellLocale" );
+       setlocale( LC_ALL, $wgShellLocale );
 }
 
 /**
@@ -2956,6 +2962,7 @@ function wfGetPrecompiledData( $name ) {
 /**
  * Make a cache key for the local wiki.
  *
+ * @deprecated since 1.30 Call makeKey on a BagOStuff instance
  * @param string $args,...
  * @return string
  */
@@ -2992,6 +2999,7 @@ function wfForeignMemcKey( $db, $prefix /*...*/ ) {
  * 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
@@ -3073,9 +3081,9 @@ function wfGetDB( $db, $groups = [], $wiki = false ) {
  */
 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 );
        }
 }
@@ -3088,7 +3096,7 @@ function wfGetLB( $wiki = false ) {
  * @return \Wikimedia\Rdbms\LBFactory
  */
 function wfGetLBFactory() {
-       return \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+       return MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
 }
 
 /**
@@ -3507,7 +3515,9 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
        }
 
        $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