Make list=logevents display log entries by anonymous users
[lhc/web/wiklou.git] / includes / CacheHelper.php
index 5209857..f0ae5a3 100644 (file)
@@ -18,7 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @licence GNU GPL v2 or later
+ * @license GNU GPL v2 or later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 
@@ -73,7 +73,8 @@ interface ICacheHelper {
        function saveCache();
 
        /**
-        * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry..
+        * Sets the time to live for the cache, in seconds or a unix timestamp
+        * indicating the point of expiry...
         *
         * @since 1.20
         *
@@ -142,10 +143,18 @@ class CacheHelper implements ICacheHelper {
         * Function that gets called when initialization is done.
         *
         * @since 1.20
-        * @var function
+        * @var callable
         */
        protected $onInitHandler = false;
 
+       /**
+        * Elements to build a cache key with.
+        *
+        * @since 1.20
+        * @var array
+        */
+       protected $cacheKey = array();
+
        /**
         * Sets if the cache should be enabled or not.
         *
@@ -319,7 +328,8 @@ class CacheHelper implements ICacheHelper {
        }
 
        /**
-        * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry..
+        * Sets the time to live for the cache, in seconds or a unix timestamp
+        * indicating the point of expiry...
         *
         * @since 1.20
         *
@@ -336,8 +346,13 @@ class CacheHelper implements ICacheHelper {
         * @since 1.20
         *
         * @return string
+        * @throws MWException
         */
        protected function getCacheKeyString() {
+               if ( $this->cacheKey === array() ) {
+                       throw new MWException( 'No cache key set, so cannot obtain or save the CacheHelper values.' );
+               }
+
                return call_user_func_array( 'wfMemcKey', $this->cacheKey );
        }