X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcache%2FCacheHelper.php;h=8c70be24a12b6282cf6af8987e0298e3128c535a;hb=9d8e15112650d87fa7728791b6bd32a7106d5554;hp=401c2b96209c2bdea7bbeb83d301b09ebda346e1;hpb=a8b5e408bf8df6a02d18c70ad22ec14f2333abd4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/CacheHelper.php b/includes/cache/CacheHelper.php index 401c2b9620..8c70be24a1 100644 --- a/includes/cache/CacheHelper.php +++ b/includes/cache/CacheHelper.php @@ -61,7 +61,7 @@ interface ICacheHelper { * * @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. @@ -82,6 +82,8 @@ interface ICacheHelper { function setExpiry( $cacheExpiry ); } +use MediaWiki\MediaWikiServices; + /** * Helper class for caching various elements in a single cache entry. * @@ -150,7 +152,7 @@ class CacheHelper implements ICacheHelper { * @since 1.20 * @var array */ - protected $cacheKey = array(); + protected $cacheKey = []; /** * Sets if the cache should be enabled or not. @@ -217,10 +219,10 @@ class CacheHelper implements ICacheHelper { $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 ); } @@ -239,7 +241,7 @@ class CacheHelper implements ICacheHelper { $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 ); @@ -261,7 +263,7 @@ class CacheHelper implements ICacheHelper { * * @return mixed */ - public function getCachedValue( $computeFunction, $args = array(), $key = null ) { + public function getCachedValue( $computeFunction, $args = [], $key = null ) { $this->initCaching(); if ( $this->cacheEnabled && $this->hasCached ) { @@ -289,7 +291,7 @@ class CacheHelper implements ICacheHelper { } } else { if ( !is_array( $args ) ) { - $args = array( $args ); + $args = [ $args ]; } $value = call_user_func_array( $computeFunction, $args ); @@ -344,7 +346,7 @@ class CacheHelper implements ICacheHelper { * @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.' ); }