Move interface ICacheHelper to own class
authorUmherirrender <umherirrender_de.wp@web.de>
Tue, 5 Feb 2019 19:04:12 +0000 (20:04 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Tue, 5 Feb 2019 19:04:12 +0000 (20:04 +0100)
Change-Id: I6f2b6507b0038f0988e4db5566ebddbe0d734a70

.phpcs.xml
autoload.php
includes/cache/CacheHelper.php
includes/cache/ICacheHelper.php [new file with mode: 0644]

index 272e0f5..3caae98 100644 (file)
@@ -82,7 +82,6 @@
                <exclude-pattern>*/includes/installer/PhpBugTests\.php</exclude-pattern>
                <exclude-pattern>*/includes/specials/SpecialMostinterwikis\.php</exclude-pattern>
                <exclude-pattern>*/includes/cache/CacheDependency\.php</exclude-pattern>
                <exclude-pattern>*/includes/installer/PhpBugTests\.php</exclude-pattern>
                <exclude-pattern>*/includes/specials/SpecialMostinterwikis\.php</exclude-pattern>
                <exclude-pattern>*/includes/cache/CacheDependency\.php</exclude-pattern>
-               <exclude-pattern>*/includes/cache/CacheHelper\.php</exclude-pattern>
                <exclude-pattern>*/includes/compat/XMPReader\.php</exclude-pattern>
                <exclude-pattern>*/includes/diff/DairikiDiff\.php</exclude-pattern>
                <exclude-pattern>*/includes/specials/SpecialAncientpages\.php</exclude-pattern>
                <exclude-pattern>*/includes/compat/XMPReader\.php</exclude-pattern>
                <exclude-pattern>*/includes/diff/DairikiDiff\.php</exclude-pattern>
                <exclude-pattern>*/includes/specials/SpecialAncientpages\.php</exclude-pattern>
                <exclude-pattern>*/includes/api/ApiRsd\.php</exclude-pattern>
                <exclude-pattern>*/includes/AuthPlugin\.php</exclude-pattern>
                <exclude-pattern>*/includes/cache/CacheDependency\.php</exclude-pattern>
                <exclude-pattern>*/includes/api/ApiRsd\.php</exclude-pattern>
                <exclude-pattern>*/includes/AuthPlugin\.php</exclude-pattern>
                <exclude-pattern>*/includes/cache/CacheDependency\.php</exclude-pattern>
-               <exclude-pattern>*/includes/cache/CacheHelper\.php</exclude-pattern>
                <exclude-pattern>*/includes/compat/XMPReader\.php</exclude-pattern>
                <exclude-pattern>*/includes/deferred/CdnCacheUpdate\.php</exclude-pattern>
                <exclude-pattern>*/includes/diff/DairikiDiff\.php</exclude-pattern>
                <exclude-pattern>*/includes/compat/XMPReader\.php</exclude-pattern>
                <exclude-pattern>*/includes/deferred/CdnCacheUpdate\.php</exclude-pattern>
                <exclude-pattern>*/includes/diff/DairikiDiff\.php</exclude-pattern>
index 348a0d2..8906211 100644 (file)
@@ -640,7 +640,7 @@ $wgAutoloadLocalClasses = [
        'HttpStatus' => __DIR__ . '/includes/libs/HttpStatus.php',
        'IApiMessage' => __DIR__ . '/includes/api/IApiMessage.php',
        'IBufferingStatsdDataFactory' => __DIR__ . '/includes/libs/stats/IBufferingStatsdDataFactory.php',
        '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',
        'IContextSource' => __DIR__ . '/includes/context/IContextSource.php',
        'IDBAccessObject' => __DIR__ . '/includes/dao/IDBAccessObject.php',
        'IDatabase' => __DIR__ . '/includes/libs/rdbms/database/IDatabase.php',
index 93685e3..d7669eb 100644 (file)
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 
  * @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;
 
 /**
 use MediaWiki\MediaWikiServices;
 
 /**
diff --git a/includes/cache/ICacheHelper.php b/includes/cache/ICacheHelper.php
new file mode 100644 (file)
index 0000000..54e9aac
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Cache of various elements in a single cache entry.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @license GPL-2.0-or-later
+ * @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 );
+}