Merge "hooks.txt: Convert docs to modern extension registration style"
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index e9853b1..ad0f67e 100644 (file)
@@ -119,7 +119,7 @@ class ObjectCache {
         * @return BagOStuff
         * @throws InvalidArgumentException
         */
-       public static function newFromId( $id ) {
+       private static function newFromId( $id ) {
                global $wgObjectCaches;
 
                if ( !isset( $wgObjectCaches[$id] ) ) {
@@ -146,7 +146,7 @@ class ObjectCache {
         *
         * @return string
         */
-       public static function getDefaultKeyspace() {
+       private static function getDefaultKeyspace() {
                global $wgCachePrefix;
 
                $keyspace = $wgCachePrefix;
@@ -178,7 +178,8 @@ class ObjectCache {
                } elseif ( isset( $params['class'] ) ) {
                        $class = $params['class'];
                        // Automatically set the 'async' update handler
-                       $params['asyncHandler'] = $params['asyncHandler'] ?? 'DeferredUpdates::addCallableUpdate';
+                       $params['asyncHandler'] = $params['asyncHandler']
+                               ?? [ DeferredUpdates::class, 'addCallableUpdate' ];
                        // Enable reportDupes by default
                        $params['reportDupes'] = $params['reportDupes'] ?? true;
                        // Do b/c logic for SqlBagOStuff
@@ -296,7 +297,7 @@ class ObjectCache {
         * @return WANObjectCache
         * @throws UnexpectedValueException
         */
-       public static function newWANCacheFromId( $id ) {
+       private static function newWANCacheFromId( $id ) {
                global $wgWANObjectCaches, $wgObjectCaches;
 
                if ( !isset( $wgWANObjectCaches[$id] ) ) {
@@ -323,7 +324,7 @@ class ObjectCache {
         * @throws UnexpectedValueException
         */
        public static function newWANCacheFromParams( array $params ) {
-               global $wgCommandLineMode;
+               global $wgCommandLineMode, $wgSecretKey;
 
                $services = MediaWikiServices::getInstance();
                $params['cache'] = self::newFromParams( $params['store'] );
@@ -334,6 +335,7 @@ class ObjectCache {
                        // Let pre-emptive refreshes happen post-send on HTTP requests
                        $params['asyncHandler'] = [ DeferredUpdates::class, 'addCallableUpdate' ];
                }
+               $params['secret'] = $params['secret'] ?? $wgSecretKey;
                $class = $params['class'];
 
                return new $class( $params );
@@ -359,24 +361,13 @@ class ObjectCache {
         * @deprecated Since 1.28 Use MediaWikiServices::getInstance()->getMainWANObjectCache()
         */
        public static function getMainWANInstance() {
+               wfDeprecated( __METHOD__, '1.28' );
                return MediaWikiServices::getInstance()->getMainWANObjectCache();
        }
 
        /**
         * Get the cache object for the main stash.
         *
-        * Stash objects are BagOStuff instances suitable for storing light
-        * weight data that is not canonically stored elsewhere (such as RDBMS).
-        * Stashes should be configured to propagate changes to all data-centers.
-        *
-        * Callers should be prepared for:
-        *   - a) Writes to be slower in non-"primary" (e.g. HTTP GET/HEAD only) DCs
-        *   - b) Reads to be eventually consistent, e.g. for get()/getMulti()
-        * In general, this means avoiding updates on idempotent HTTP requests and
-        * avoiding an assumption of perfect serializability (or accepting anomalies).
-        * Reads may be eventually consistent or data might rollback as nodes flap.
-        * Callers can use BagOStuff:READ_LATEST to see the latest available data.
-        *
         * @return BagOStuff
         * @since 1.26
         * @deprecated Since 1.28 Use MediaWikiServices::getInstance()->getMainObjectStash()