Move Config::set() to MutableConfig::set()
authorKunal Mehta <legoktm@gmail.com>
Wed, 10 Sep 2014 21:51:16 +0000 (14:51 -0700)
committerKunal Mehta <legoktm@gmail.com>
Thu, 11 Sep 2014 15:26:43 +0000 (08:26 -0700)
Introduces a new interface for Config types
that are mutable. Not all Config instances
should be mutable, like MultiConfig.

Change-Id: I56e193cbbf72b7afdf551f60ea635fc347e14b3e

includes/AutoLoader.php
includes/config/Config.php
includes/config/GlobalVarConfig.php
includes/config/MutableConfig.php [new file with mode: 0644]
tests/phpunit/includes/config/GlobalVarConfigTest.php

index 87cd5d5..4c35bfd 100644 (file)
@@ -374,6 +374,7 @@ $wgAutoloadLocalClasses = array(
        'ConfigException' => 'includes/config/ConfigException.php',
        'ConfigFactory' => 'includes/config/ConfigFactory.php',
        'GlobalVarConfig' => 'includes/config/GlobalVarConfig.php',
+       'MutableConfig' => 'includes/config/MutableConfig.php',
 
        # includes/content
        'AbstractContent' => 'includes/content/AbstractContent.php',
index 68e90b4..03d2cb9 100644 (file)
@@ -35,13 +35,4 @@ interface Config {
         * @throws ConfigException
         */
        public function get( $name );
-
-       /**
-        * Set a configuration variable such a "Sitename" to something like "My Wiki"
-        *
-        * @param string $name Name of configuration option
-        * @param mixed $value Value to set
-        * @throws ConfigException
-        */
-       public function set( $name, $value );
 }
index 0841a00..1144384 100644 (file)
@@ -53,9 +53,11 @@ class GlobalVarConfig implements Config {
        }
 
        /**
-        * @see Config::set
+        * @see MutableConfig::set
+        * @deprecated since 1.24
         */
        public function set( $name, $value ) {
+               wfDeprecated( __METHOD__, '1.24' );
                $this->setWithPrefix( $this->prefix, $name, $value );
        }
 
@@ -81,6 +83,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;
diff --git a/includes/config/MutableConfig.php b/includes/config/MutableConfig.php
new file mode 100644 (file)
index 0000000..e765e3b
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Copyright 2014
+ *
+ * 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
+ */
+
+/**
+ * Interface for mutable configuration instances
+ *
+ * @since 1.24
+ */
+interface MutableConfig {
+
+       /**
+        * Set a configuration variable such a "Sitename" to something like "My Wiki"
+        *
+        * @param string $name Name of configuration option
+        * @param mixed $value Value to set
+        * @throws ConfigException
+        */
+       public function set( $name, $value );
+}
index a999081..b15ffa7 100644 (file)
@@ -97,6 +97,7 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
         * @covers GlobalVarConfig::setWithPrefix
         */
        public function testSet( $name, $prefix, $var ) {
+               $this->hideDeprecated( 'GlobalVarConfig::set' );
                $this->maybeStashGlobal( $var );
                $config = new GlobalVarConfig( $prefix );
                $random = wfRandomString();