$storeClass = 'LCStore_Accel';
break;
case 'detect':
- try {
- $c = wfGetCache( CACHE_ACCEL );
- $storeClass = 'LCStore_Accel';
- } catch( Exception $c ) {
- $storeClass = $wgCacheDirectory ? 'LCStore_CDB' : 'LCStore_DB';
- }
+ $storeClass = $wgCacheDirectory ? 'LCStore_CDB' : 'LCStore_DB';
break;
default:
throw new MWException(
* @return bool
*/
public function isMergeableKey( $key ) {
- if ( !isset( $this->mergeableKeys ) ) {
+ if ( $this->mergeableKeys === null ) {
$this->mergeableKeys = array_flip( array_merge(
- self::$mergeableMapKeys,
- self::$mergeableListKeys,
- self::$mergeableAliasListKeys,
- self::$optionalMergeKeys,
- self::$magicWordKeys
- ) );
+ self::$mergeableMapKeys,
+ self::$mergeableListKeys,
+ self::$mergeableAliasListKeys,
+ self::$optionalMergeKeys,
+ self::$magicWordKeys
+ ) );
}
return isset( $this->mergeableKeys[$key] );
}
* need to fetch all of the subitems from the cache individually.
* @param $code
* @param $key
- * @return string
+ * @return mixed
*/
public function getItem( $code, $key ) {
if ( !isset( $this->loadedItems[$code][$key] ) ) {
/**
* Returns true if the cache identified by $code is missing or expired.
+ * @return bool
*/
public function isExpired( $code ) {
if ( $this->forceRecache && !isset( $this->recachedLangs[$code] ) ) {
$deps = $this->store->get( $code, 'deps' );
$keys = $this->store->get( $code, 'list', 'messages' );
- // 'list:messages' sometimes expires separately of 'deps' in LCStore_Accel
- if ( $deps === null || $keys === null ) {
+ $preload = $this->store->get( $code, 'preload' );
+ // Different keys may expire separately, at least in LCStore_Accel
+ if ( $deps === null || $keys === null || $preload === null ) {
wfDebug( __METHOD__."($code): cache missing, need to make one\n" );
return true;
}
$oldSynonyms = array_slice( $fallbackInfo, 1 );
$newSynonyms = array_slice( $value[$magicName], 1 );
$synonyms = array_values( array_unique( array_merge(
- $newSynonyms, $oldSynonyms ) ) );
+ $newSynonyms, $oldSynonyms ) ) );
$value[$magicName] = array_merge( array( $fallbackInfo[0] ), $synonyms );
}
}
* @param $code
*/
public function recache( $code ) {
- global $wgExtensionMessagesFiles, $wgExtensionAliasesFiles;
+ global $wgExtensionMessagesFiles;
wfProfileIn( __METHOD__ );
if ( !$code ) {
}
}
- # Load deprecated $wgExtensionAliasesFiles
- foreach ( $wgExtensionAliasesFiles as $fileName ) {
- $data = $this->readPHPFile( $fileName, 'aliases' );
-
- if ( !isset( $data['aliases'] ) ) {
- continue;
- }
-
- $used = $this->mergeExtensionItem( $codeSequence, 'specialPageAliases',
- $allData['specialPageAliases'], $data['aliases'] );
-
- if ( $used ) {
- $deps[] = new FileDependency( $fileName );
- }
- }
-
# Merge core data into extension data
foreach ( $coreData as $key => $item ) {
$this->mergeItem( $key, $allData[$key], $item );
# Add cache dependencies for any referenced globals
$deps['wgExtensionMessagesFiles'] = new GlobalDependency( 'wgExtensionMessagesFiles' );
- $deps['wgExtensionAliasesFiles'] = new GlobalDependency( 'wgExtensionAliasesFiles' );
$deps['version'] = new ConstantDependency( 'MW_LC_VERSION' );
# Add dependencies to the cache entry
interface LCStore {
/**
* Get a value.
- * @param $code Language code
- * @param $key Cache key
+ * @param $code string Language code
+ * @param $key string Cache key
*/
function get( $code, $key );
/**
* LCStore implementation which uses PHP accelerator to store data.
- * This will work if one of XCache, eAccelerator, or APC cacher is configured.
+ * This will work if one of XCache, WinCache or APC cacher is configured.
* (See ObjectCache.php)
*/
class LCStore_Accel implements LCStore {
public function get( $code, $key ) {
$k = wfMemcKey( 'l10n', $code, 'k', $key );
$r = $this->cache->get( $k );
- if ( $r === false ) return null;
- return $r;
+ return $r === false ? null : $r;
}
public function startWrite( $code ) {
/**
* @param $code
* @param $key
- * @return string
+ * @return mixed
*/
public function getItem( $code, $key ) {
unset( $this->mruLangs[$code] );
$this->unload( $code );
}
}
-}
\ No newline at end of file
+}