break;
default:
throw new MWException(
- 'Please set $wgLocalisationConf[\'store\'] to something sensible.' );
+ 'Please set $wgLocalisationCacheConf[\'store\'] to something sensible.' );
}
}
if ( isset( $this->legacyData[$code][$key][$subkey] ) ) {
return $this->legacyData[$code][$key][$subkey];
}
- if ( !isset( $this->loadedSubitems[$code][$key][$subkey] ) ) {
- if ( isset( $this->loadedItems[$code][$key] ) ) {
- if ( isset( $this->data[$code][$key][$subkey] ) ) {
- return $this->data[$code][$key][$subkey];
- } else {
- return null;
- }
+ if ( !isset( $this->loadedSubitems[$code][$key][$subkey] )
+ && !isset( $this->loadedItems[$code][$key] ) )
+ {
+ wfProfileIn( __METHOD__.'-load' );
+ $this->loadSubitem( $code, $key, $subkey );
+ wfProfileOut( __METHOD__.'-load' );
+ }
+ if ( isset( $this->data[$code][$key][$subkey] ) ) {
+ return $this->data[$code][$key][$subkey];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Get the list of subitem keys for a given item.
+ *
+ * This is faster than array_keys($lc->getItem(...)) for the items listed in
+ * self::$splitKeys.
+ *
+ * Will return null if the item is not found, or false if the item is not an
+ * array.
+ */
+ public function getSubitemList( $code, $key ) {
+ if ( in_array( $key, self::$splitKeys ) ) {
+ return $this->getSubitem( $code, 'list', $key );
+ } else {
+ $item = $this->getItem( $code, $key );
+ if ( is_array( $item ) ) {
+ return array_keys( $item );
} else {
- wfProfileIn( __METHOD__.'-load' );
- $this->loadSubitem( $code, $key, $subkey );
- wfProfileOut( __METHOD__.'-load' );
+ return false;
}
}
- return $this->data[$code][$key][$subkey];
}
/**
$this->initLanguage( $code );
}
// Check to see if initLanguage() loaded it for us
- if ( isset( $this->loadedSubitems[$code][$key][$subkey] ) ) {
+ if ( isset( $this->loadedItems[$code][$key] )
+ || isset( $this->loadedSubitems[$code][$key][$subkey] ) )
+ {
return;
}
if ( isset( $this->shallowFallbacks[$code] ) ) {
return true;
}
foreach ( $deps as $dep ) {
- if ( $dep->isExpired() ) {
+ // Because we're unserializing stuff from cache, we
+ // could receive objects of classes that don't exist
+ // anymore (e.g. uninstalled extensions)
+ // When this happens, always expire the cache
+ if ( !$dep instanceof CacheDependency || $dep->isExpired() ) {
wfDebug( __METHOD__."($code): cache for $code expired due to " .
get_class( $dep ) . "\n" );
return true;
*/
protected function readPHPFile( $_fileName, $_fileType ) {
// Disable APC caching
- $_apcEnabled = ini_set( 'apc.enabled', '0' );
+ $_apcEnabled = ini_set( 'apc.cache_by_default', '0' );
include( $_fileName );
- ini_set( 'apc.enabled', $_apcEnabled );
+ ini_set( 'apc.cache_by_default', $_apcEnabled );
if ( $_fileType == 'core' || $_fileType == 'extension' ) {
$data = compact( self::$allKeys );
$allData['defaultUserOptionOverrides'] = array();
}
- # Set the preload key
- $allData['preload'] = $this->buildPreload( $allData );
-
# Set the list keys
$allData['list'] = array();
foreach ( self::$splitKeys as $key ) {
'Check that your languages/messages/MessagesEn.php file is intact.' );
}
+ # Set the preload key
+ $allData['preload'] = $this->buildPreload( $allData );
+
# Save to the process cache and register the items loaded
$this->data[$code] = $allData;
foreach ( $allData as $key => $item ) {
}
}
$this->store->finishWrite();
+
+ # Clear out the MessageBlobStore
+ # HACK: If using a null (i.e. disabled) storage backend, we
+ # can't write to the MessageBlobStore either
+ if ( !$this->store instanceof LCStore_Null ) {
+ MessageBlobStore::clear();
+ }
wfProfileOut( __METHOD__ );
}
*/
public function disableBackend() {
$this->store = new LCStore_Null;
+ $this->manualRecache = false;
}
}
* @param $code Language code
* @param $key Cache key
*/
- public function get( $code, $key );
+ function get( $code, $key );
/**
* Start a write transaction.
* @param $code Language code
*/
- public function startWrite( $code );
+ function startWrite( $code );
/**
* Finish a write transaction.
*/
- public function finishWrite();
+ function finishWrite();
/**
* Set a key to a given value. startWrite() must be called before this
* is called, and finishWrite() must be called afterwards.
*/
- public function set( $key, $value );
+ function set( $key, $value );
}