r83147 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83146‎ | r83147 | r83148 >
Date:15:24, 3 March 2011
Author:tstarling
Status:ok
Tags:
Comment:
* When CACHE_ANYTHING is requested, return the cached instance, don't construct a new object for each use.
* 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.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/MemcachedSessions.php (modified) (history)
  • /trunk/phase3/includes/objectcache/ObjectCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/objectcache/ObjectCache.php
@@ -58,10 +58,10 @@
5959 $candidates = array( $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType );
6060 foreach ( $candidates as $candidate ) {
6161 if ( $candidate !== CACHE_NONE && $candidate !== CACHE_ANYTHING ) {
62 - return self::newFromId( $candidate );
 62+ return self::getInstance( $candidate );
6363 }
6464 }
65 - return self::newFromId( CACHE_DB );
 65+ return self::getInstance( CACHE_DB );
6666 }
6767
6868 /**
Index: trunk/phase3/includes/MemcachedSessions.php
@@ -92,4 +92,14 @@
9393 return true;
9494 }
9595
 96+function memsess_write_close() {
 97+ session_write_close();
 98+}
 99+
96100 session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read', 'memsess_write', 'memsess_destroy', 'memsess_gc' );
 101+
 102+// It's necessary to register a shutdown function to call session_write_close(),
 103+// because by the time the request shutdown function for the session module is
 104+// called, $wgMemc has already been destroyed. Shutdown functions registered
 105+// this way are called before object destruction.
 106+register_shutdown_function( 'memsess_write_close' );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1519,7 +1519,7 @@
15201520 * The other parameters are dependent on the class used.
15211521 */
15221522 $wgObjectCaches = array(
1523 - CACHE_NONE => array( 'class' => 'FakeMemCachedClient' ),
 1523+ CACHE_NONE => array( 'class' => 'EmptyBagOStuff' ),
15241524 CACHE_DB => array( 'class' => 'SqlBagOStuff', 'table' => 'objectcache' ),
15251525 CACHE_DBA => array( 'class' => 'DBABagOStuff' ),
15261526

Sign-offs

UserFlagDate
Siebrandtested16:02, 3 March 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r84727Merged in the ObjectCache refactor and the Ehcache client. MFT r83135, r83136...tstarling03:28, 25 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83140* Rewrote ObjectCache.php to conform to the modern coding style, and to be le...tstarling09:37, 3 March 2011

Status & tagging log