* When CACHE_ANYTHING is requested, return the cached instance, don't construct a...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 3 Mar 2011 15:24:51 +0000 (15:24 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 3 Mar 2011 15:24:51 +0000 (15:24 +0000)
* In MemcachedSessions.php, register a shutdown function to shut down the session early, before $wgMemc is destroyed. I'm not sure why my recent changes caused this problem to show up now.
* Use EmptyBagOStuff instead of FakeMemCachedClient in DefaultSettings.php for CACHE_NONE.

includes/DefaultSettings.php
includes/MemcachedSessions.php
includes/objectcache/ObjectCache.php

index 37c64cf..31f1f93 100644 (file)
@@ -1519,7 +1519,7 @@ $wgParserCacheType = CACHE_ANYTHING;
  * The other parameters are dependent on the class used.
  */
 $wgObjectCaches = array(
-       CACHE_NONE => array( 'class' => 'FakeMemCachedClient' ),
+       CACHE_NONE => array( 'class' => 'EmptyBagOStuff' ),
        CACHE_DB => array( 'class' => 'SqlBagOStuff', 'table' => 'objectcache' ),
        CACHE_DBA => array( 'class' => 'DBABagOStuff' ),
 
index 4f10f99..3825a3b 100644 (file)
@@ -92,4 +92,14 @@ function memsess_gc( $maxlifetime ) {
        return true;
 }
 
+function memsess_write_close() {
+       session_write_close();
+}
+
 session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read', 'memsess_write', 'memsess_destroy', 'memsess_gc' );
+
+// It's necessary to register a shutdown function to call session_write_close(), 
+// because by the time the request shutdown function for the session module is 
+// called, $wgMemc has already been destroyed. Shutdown functions registered
+// this way are called before object destruction.
+register_shutdown_function( 'memsess_write_close' );
index 96dd4cf..5155c0d 100644 (file)
@@ -58,10 +58,10 @@ class ObjectCache {
                $candidates = array( $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType );
                foreach ( $candidates as $candidate ) {
                        if ( $candidate !== CACHE_NONE && $candidate !== CACHE_ANYTHING ) {
-                               return self::newFromId( $candidate );
+                               return self::getInstance( $candidate );
                        }
                }
-               return self::newFromId( CACHE_DB );
+               return self::getInstance( CACHE_DB );
        }
 
        /**