X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcache%2FCacheDependency.php;h=a59ba97d0a007311e1ba5872265e6ba3f422fb2d;hb=82a95e69ab2e576a5687138f29d0abbd21ad8c0e;hp=2d29d8651306d1803e8c8eed9daf43d483d429be;hpb=9ba3fca2d8adc56787c8efc32c41424cb212e387;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/CacheDependency.php b/includes/cache/CacheDependency.php index 2d29d86513..a59ba97d0a 100644 --- a/includes/cache/CacheDependency.php +++ b/includes/cache/CacheDependency.php @@ -20,6 +20,7 @@ * @file * @ingroup Cache */ +use MediaWiki\MediaWikiServices; /** * This class stores an arbitrary value along with its dependencies. @@ -244,6 +245,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 */