From 1c851623b0c82a80ed368462a0711ab30fffb0c6 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Tue, 5 Feb 2019 20:04:12 +0100 Subject: [PATCH] Move interface ICacheHelper to own class Change-Id: I6f2b6507b0038f0988e4db5566ebddbe0d734a70 --- .phpcs.xml | 2 - autoload.php | 2 +- includes/cache/CacheHelper.php | 60 ------------------------ includes/cache/ICacheHelper.php | 83 +++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 63 deletions(-) create mode 100644 includes/cache/ICacheHelper.php diff --git a/.phpcs.xml b/.phpcs.xml index 272e0f5ff7..3caae98684 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -82,7 +82,6 @@ */includes/installer/PhpBugTests\.php */includes/specials/SpecialMostinterwikis\.php */includes/cache/CacheDependency\.php - */includes/cache/CacheHelper\.php */includes/compat/XMPReader\.php */includes/diff/DairikiDiff\.php */includes/specials/SpecialAncientpages\.php @@ -225,7 +224,6 @@ */includes/api/ApiRsd\.php */includes/AuthPlugin\.php */includes/cache/CacheDependency\.php - */includes/cache/CacheHelper\.php */includes/compat/XMPReader\.php */includes/deferred/CdnCacheUpdate\.php */includes/diff/DairikiDiff\.php diff --git a/autoload.php b/autoload.php index 348a0d2050..8906211ac1 100644 --- a/autoload.php +++ b/autoload.php @@ -640,7 +640,7 @@ $wgAutoloadLocalClasses = [ 'HttpStatus' => __DIR__ . '/includes/libs/HttpStatus.php', 'IApiMessage' => __DIR__ . '/includes/api/IApiMessage.php', 'IBufferingStatsdDataFactory' => __DIR__ . '/includes/libs/stats/IBufferingStatsdDataFactory.php', - 'ICacheHelper' => __DIR__ . '/includes/cache/CacheHelper.php', + 'ICacheHelper' => __DIR__ . '/includes/cache/ICacheHelper.php', 'IContextSource' => __DIR__ . '/includes/context/IContextSource.php', 'IDBAccessObject' => __DIR__ . '/includes/dao/IDBAccessObject.php', 'IDatabase' => __DIR__ . '/includes/libs/rdbms/database/IDatabase.php', diff --git a/includes/cache/CacheHelper.php b/includes/cache/CacheHelper.php index 93685e35af..d7669eb1b9 100644 --- a/includes/cache/CacheHelper.php +++ b/includes/cache/CacheHelper.php @@ -22,66 +22,6 @@ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -/** - * Interface for all classes implementing CacheHelper functionality. - * - * @since 1.20 - */ -interface ICacheHelper { - /** - * Sets if the cache should be enabled or not. - * - * @since 1.20 - * @param bool $cacheEnabled - */ - function setCacheEnabled( $cacheEnabled ); - - /** - * Initializes the caching. - * Should be called before the first time anything is added via addCachedHTML. - * - * @since 1.20 - * - * @param int|null $cacheExpiry Sets the cache expiry, either ttl in seconds or unix timestamp. - * @param bool|null $cacheEnabled Sets if the cache should be enabled or not. - */ - function startCache( $cacheExpiry = null, $cacheEnabled = null ); - - /** - * Get a cached value if available or compute it if not and then cache it if possible. - * The provided $computeFunction is only called when the computation needs to happen - * and should return a result value. $args are arguments that will be passed to the - * compute function when called. - * - * @since 1.20 - * - * @param callable $computeFunction - * @param array|mixed $args - * @param string|null $key - * - * @return mixed - */ - function getCachedValue( $computeFunction, $args = [], $key = null ); - - /** - * Saves the HTML to the cache in case it got recomputed. - * Should be called after the last time anything is added via addCachedHTML. - * - * @since 1.20 - */ - function saveCache(); - - /** - * Sets the time to live for the cache, in seconds or a unix timestamp - * indicating the point of expiry... - * - * @since 1.20 - * - * @param int $cacheExpiry - */ - function setExpiry( $cacheExpiry ); -} - use MediaWiki\MediaWikiServices; /** diff --git a/includes/cache/ICacheHelper.php b/includes/cache/ICacheHelper.php new file mode 100644 index 0000000000..54e9aac7e3 --- /dev/null +++ b/includes/cache/ICacheHelper.php @@ -0,0 +1,83 @@ + + */ + +/** + * Interface for all classes implementing CacheHelper functionality. + * + * @since 1.20 + */ +interface ICacheHelper { + /** + * Sets if the cache should be enabled or not. + * + * @since 1.20 + * @param bool $cacheEnabled + */ + function setCacheEnabled( $cacheEnabled ); + + /** + * Initializes the caching. + * Should be called before the first time anything is added via addCachedHTML. + * + * @since 1.20 + * + * @param int|null $cacheExpiry Sets the cache expiry, either ttl in seconds or unix timestamp. + * @param bool|null $cacheEnabled Sets if the cache should be enabled or not. + */ + function startCache( $cacheExpiry = null, $cacheEnabled = null ); + + /** + * Get a cached value if available or compute it if not and then cache it if possible. + * The provided $computeFunction is only called when the computation needs to happen + * and should return a result value. $args are arguments that will be passed to the + * compute function when called. + * + * @since 1.20 + * + * @param callable $computeFunction + * @param array|mixed $args + * @param string|null $key + * + * @return mixed + */ + function getCachedValue( $computeFunction, $args = [], $key = null ); + + /** + * Saves the HTML to the cache in case it got recomputed. + * Should be called after the last time anything is added via addCachedHTML. + * + * @since 1.20 + */ + function saveCache(); + + /** + * Sets the time to live for the cache, in seconds or a unix timestamp + * indicating the point of expiry... + * + * @since 1.20 + * + * @param int $cacheExpiry + */ + function setExpiry( $cacheExpiry ); +} -- 2.20.1