X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fconfig%2FGlobalVarConfig.php;h=39d6e8e1dbf743be0c5e44363f855623a6ffb518;hb=0755177e64facf9b2f7c7b0937e669e1a0ff4a7f;hp=0841a00419767dd1fe309b2a0822545411b49b19;hpb=7b3eee1be0be4e862921190df927e5b3a86a8095;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/config/GlobalVarConfig.php b/includes/config/GlobalVarConfig.php index 0841a00419..39d6e8e1db 100644 --- a/includes/config/GlobalVarConfig.php +++ b/includes/config/GlobalVarConfig.php @@ -49,13 +49,25 @@ class GlobalVarConfig implements Config { * @see Config::get */ public function get( $name ) { + if ( !$this->has( $name ) ) { + throw new ConfigException( __METHOD__ . ": undefined option: '$name'" ); + } return $this->getWithPrefix( $this->prefix, $name ); } /** - * @see Config::set + * @see Config::has + */ + public function has( $name ) { + return $this->hasWithPrefix( $this->prefix, $name ); + } + + /** + * @see MutableConfig::set + * @deprecated since 1.24 */ public function set( $name, $value ) { + wfDeprecated( __METHOD__, '1.24' ); $this->setWithPrefix( $this->prefix, $name, $value ); } @@ -64,15 +76,22 @@ class GlobalVarConfig implements Config { * * @param string $prefix Prefix to use on the variable, if one. * @param string $name Variable name without prefix - * @throws ConfigException * @return mixed */ protected function getWithPrefix( $prefix, $name ) { + return $GLOBALS[$prefix . $name]; + } + + /** + * Check if a variable with a given prefix is set + * + * @param string $prefix Prefix to use on the variable + * @param string $name Variable name without prefix + * @return bool + */ + protected function hasWithPrefix( $prefix, $name ) { $var = $prefix . $name; - if ( !array_key_exists( $var, $GLOBALS ) ) { - throw new ConfigException( __METHOD__ . ": undefined variable: '$var'" ); - } - return $GLOBALS[$var]; + return array_key_exists( $var, $GLOBALS ); } /** @@ -81,6 +100,7 @@ class GlobalVarConfig implements Config { * @param string $prefix Prefix to use on the variable * @param string $name Variable name without prefix * @param mixed $value Value to set + * @deprecated since 1.24 */ protected function setWithPrefix( $prefix, $name, $value ) { $GLOBALS[$prefix . $name] = $value;