*
* @return mixed
*/
- function getCachedValue( $computeFunction, $args = array(), $key = null );
+ function getCachedValue( $computeFunction, $args = [], $key = null );
/**
* Saves the HTML to the cache in case it got recomputed.
function setExpiry( $cacheExpiry );
}
+use MediaWiki\MediaWikiServices;
+
/**
* Helper class for caching various elements in a single cache entry.
*
* @since 1.20
* @var array
*/
- protected $cacheKey = array();
+ protected $cacheKey = [];
/**
* Sets if the cache should be enabled or not.
$subPage = explode( '/', $subPage, 2 );
$subPage = count( $subPage ) > 1 ? $subPage[1] : false;
- $message .= ' ' . Linker::link(
+ $message .= ' ' . MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
$context->getTitle( $subPage ),
- $context->msg( 'cachedspecial-refresh-now' )->escaped(),
- array(),
+ $context->msg( 'cachedspecial-refresh-now' )->text(),
+ [],
$refreshArgs
);
}
$cachedChunks = wfGetCache( CACHE_ANYTHING )->get( $this->getCacheKeyString() );
$this->hasCached = is_array( $cachedChunks );
- $this->cachedChunks = $this->hasCached ? $cachedChunks : array();
+ $this->cachedChunks = $this->hasCached ? $cachedChunks : [];
if ( $this->onInitHandler !== false ) {
call_user_func( $this->onInitHandler, $this->hasCached );
*
* @return mixed
*/
- public function getCachedValue( $computeFunction, $args = array(), $key = null ) {
+ public function getCachedValue( $computeFunction, $args = [], $key = null ) {
$this->initCaching();
if ( $this->cacheEnabled && $this->hasCached ) {
}
} else {
if ( !is_array( $args ) ) {
- $args = array( $args );
+ $args = [ $args ];
}
$value = call_user_func_array( $computeFunction, $args );
* @throws MWException
*/
protected function getCacheKeyString() {
- if ( $this->cacheKey === array() ) {
+ if ( $this->cacheKey === [] ) {
throw new MWException( 'No cache key set, so cannot obtain or save the CacheHelper values.' );
}