objectcache: Make first parameter of newAccelerator optional
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 24 Aug 2015 20:46:54 +0000 (22:46 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 24 Aug 2015 21:43:19 +0000 (23:43 +0200)
Makes it more convenient to use.

Change-Id: I1e11f7a759bd2816e47d1c2453cbe39b8f44b2f0

includes/TemplateParser.php
includes/cache/MessageCache.php
includes/db/LoadMonitorMySQL.php
includes/filebackend/SwiftFileBackend.php
includes/filebackend/lockmanager/DBLockManager.php
includes/objectcache/ObjectCache.php
includes/registration/ExtensionRegistry.php
includes/utils/MWCryptHKDF.php
includes/utils/UIDGenerator.php

index f0a1ebb..d6b101b 100644 (file)
@@ -103,7 +103,7 @@ class TemplateParser {
                        // See if the compiled PHP code is stored in cache.
                        // CACHE_ACCEL throws an exception if no suitable object cache is present, so fall
                        // back to CACHE_ANYTHING.
-                       $cache = ObjectCache::newAccelerator( array(), CACHE_ANYTHING );
+                       $cache = ObjectCache::newAccelerator( CACHE_ANYTHING );
                        $key = wfMemcKey( 'template', $templateName, $fastHash );
                        $code = $this->forceRecompile ? null : $cache->get( $key );
 
index dafb59d..f11a648 100644 (file)
@@ -160,7 +160,7 @@ class MessageCache {
                $this->mExpiry = $expiry;
 
                if ( $wgUseLocalMessageCache ) {
-                       $this->localCache = ObjectCache::newAccelerator( array(), CACHE_NONE );
+                       $this->localCache = ObjectCache::newAccelerator( CACHE_NONE );
                } else {
                        $this->localCache = wfGetCache( CACHE_NONE );
                }
index c80697b..752d009 100644 (file)
@@ -38,7 +38,7 @@ class LoadMonitorMySQL implements LoadMonitor {
 
                $this->parent = $parent;
 
-               $this->srvCache = ObjectCache::newAccelerator( array(), 'hash' );
+               $this->srvCache = ObjectCache::newAccelerator( 'hash' );
                $this->mainCache = $wgMemc ?: wfGetMainCache();
        }
 
index 6a0f2ee..b49c4c5 100644 (file)
@@ -139,7 +139,7 @@ class SwiftFileBackend extends FileBackendStore {
                                $this->srvCache = wfGetMainCache(); // preferrably memcached
                        } else {
                                try { // look for APC, XCache, WinCache, ect...
-                                       $this->srvCache = ObjectCache::newAccelerator( array() );
+                                       $this->srvCache = ObjectCache::newAccelerator();
                                } catch ( Exception $e ) {
                                }
                        }
index 39a5563..b81cf3e 100644 (file)
@@ -96,7 +96,7 @@ abstract class DBLockManager extends QuorumLockManager {
                                // Tracks peers that couldn't be queried recently to avoid lengthy
                                // connection timeouts. This is useless if each bucket has one peer.
                                try {
-                                       $this->statusCache = ObjectCache::newAccelerator( array() );
+                                       $this->statusCache = ObjectCache::newAccelerator();
                                } catch ( Exception $e ) {
                                        trigger_error( __CLASS__ .
                                                " using multiple DB peers without apc, xcache, or wincache." );
index 8a99f53..5872831 100644 (file)
@@ -158,12 +158,15 @@ class ObjectCache {
         * This will look for any APC style server-local cache.
         * A fallback cache can be specified if none is found.
         *
-        * @param array $params
+        * @param array $params [optional]
         * @param int|string $fallback Fallback cache, e.g. (CACHE_NONE, "hash") (since 1.24)
         * @return BagOStuff
         * @throws MWException
         */
-       static function newAccelerator( $params, $fallback = null ) {
+       static function newAccelerator( $params = array(), $fallback = null ) {
+               if ( !is_array( $params ) && $fallback === null ) {
+                       $fallback = $params;
+               }
                if ( function_exists( 'apc_fetch' ) ) {
                        $id = 'apc';
                } elseif ( function_exists( 'xcache_get' ) && wfIniGetBool( 'xcache.var_size' ) ) {
index 7414925..b89518a 100644 (file)
@@ -81,7 +81,7 @@ class ExtensionRegistry {
                // we don't want to fail here if $wgObjectCaches is not configured
                // properly for APC setup
                try {
-                       $this->cache = ObjectCache::newAccelerator( array() );
+                       $this->cache = ObjectCache::newAccelerator();
                } catch ( MWException $e ) {
                        $this->cache = new EmptyBagOStuff();
                }
index 950dd84..1ddd119 100644 (file)
@@ -177,7 +177,7 @@ class MWCryptHKDF {
 
                // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
                try {
-                       $cache = ObjectCache::newAccelerator( array() );
+                       $cache = ObjectCache::newAccelerator();
                } catch ( Exception $e ) {
                        $cache = wfGetMainCache();
                }
index 2d7d932..04c8e19 100644 (file)
@@ -283,7 +283,7 @@ class UIDGenerator {
                $cache = null;
                if ( ( $flags & self::QUICK_VOLATILE ) && PHP_SAPI !== 'cli' ) {
                        try {
-                               $cache = ObjectCache::newAccelerator( array() );
+                               $cache = ObjectCache::newAccelerator();
                        } catch ( Exception $e ) {
                                // not supported
                        }