Merge "Add semantic tags to license info text"
[lhc/web/wiklou.git] / includes / cache / CacheDependency.php
index 2d29d86..dd4c49e 100644 (file)
@@ -20,6 +20,7 @@
  * @file
  * @ingroup Cache
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * This class stores an arbitrary value along with its dependencies.
@@ -33,7 +34,6 @@ class DependencyWrapper {
        private $deps;
 
        /**
-        * Create an instance.
         * @param mixed $value The user-supplied value
         * @param CacheDependency|CacheDependency[] $deps A dependency or dependency
         *   array. All dependencies must be objects implementing CacheDependency.
@@ -244,6 +244,34 @@ class GlobalDependency extends CacheDependency {
        }
 }
 
+/**
+ * @ingroup Cache
+ */
+class MainConfigDependency extends CacheDependency {
+       private $name;
+       private $value;
+
+       function __construct( $name ) {
+               $this->name = $name;
+               $this->value = $this->getConfig()->get( $this->name );
+       }
+
+       private function getConfig() {
+               return MediaWikiServices::getInstance()->getMainConfig();
+       }
+
+       /**
+        * @return bool
+        */
+       function isExpired() {
+               if ( !$this->getConfig()->has( $this->name ) ) {
+                       return true;
+               }
+
+               return $this->getConfig()->get( $this->name ) != $this->value;
+       }
+}
+
 /**
  * @ingroup Cache
  */