data */ private $maxLoadedLangs = 10; /** * @param string $fileName * @param string $fileType * @return array|mixed */ protected function readPHPFile( $fileName, $fileType ) { $serialize = $fileType === 'core'; if ( !isset( $this->fileCache[$fileName][$fileType] ) ) { $data = parent::readPHPFile( $fileName, $fileType ); if ( $serialize ) { $encData = serialize( $data ); } else { $encData = $data; } $this->fileCache[$fileName][$fileType] = $encData; return $data; } elseif ( $serialize ) { return unserialize( $this->fileCache[$fileName][$fileType] ); } else { return $this->fileCache[$fileName][$fileType]; } } /** * @param string $code * @param string $key * @return mixed */ public function getItem( $code, $key ) { unset( $this->mruLangs[$code] ); $this->mruLangs[$code] = true; return parent::getItem( $code, $key ); } /** * @param string $code * @param string $key * @param string $subkey * @return mixed */ public function getSubitem( $code, $key, $subkey ) { unset( $this->mruLangs[$code] ); $this->mruLangs[$code] = true; return parent::getSubitem( $code, $key, $subkey ); } /** * @param string $code */ public function recache( $code ) { parent::recache( $code ); unset( $this->mruLangs[$code] ); $this->mruLangs[$code] = true; $this->trimCache(); } /** * @param string $code */ public function unload( $code ) { unset( $this->mruLangs[$code] ); parent::unload( $code ); } /** * Unload cached languages until there are less than $this->maxLoadedLangs */ protected function trimCache() { while ( count( $this->data ) > $this->maxLoadedLangs && count( $this->mruLangs ) ) { reset( $this->mruLangs ); $code = key( $this->mruLangs ); wfDebug( __METHOD__ . ": unloading $code\n" ); $this->unload( $code ); } } }