Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'ticket/erikfrerejean/10006' into develop

  • Loading branch information...
commit 8fe75aefbbb0304f1335441465e566b572168365 2 parents dcfab4e + 27bbfde
@p p authored
View
13 phpBB/includes/config/config.php
@@ -104,6 +104,19 @@ public function count()
}
/**
+ * Removes a configuration option
+ *
+ * @param String $key The configuration option's name
+ * @param bool $cache Whether this variable should be cached or if it
+ * changes too frequently to be efficiently cached
+ * @return void
+ */
+ public function delete($key, $cache = true)
+ {
+ unset($this->config[$key]);
+ }
+
+ /**
* Sets a configuration option's value
*
* @param string $key The configuration option's name
View
22 phpBB/includes/config/db.php
@@ -91,6 +91,28 @@ public function __construct(dbal $db, phpbb_cache_driver_interface $cache, $tabl
}
/**
+ * Removes a configuration option
+ *
+ * @param String $key The configuration option's name
+ * @param bool $cache Whether this variable should be cached or if it
+ * changes too frequently to be efficiently cached
+ * @return void
+ */
+ public function delete($key, $cache = true)
+ {
+ $sql = 'DELETE FROM ' . $this->table . "
+ WHERE config_name = '" . $this->db->sql_escape($key) . "'";
+ $this->db->sql_query($sql);
+
+ unset($this->config[$key]);
+
+ if ($cache)
+ {
+ $this->cache->destroy('config');
+ }
+ }
+
+ /**
* Sets a configuration option's value
*
* @param string $key The configuration option's name
View
8 tests/config/config_test.php
@@ -109,4 +109,12 @@ public function test_increment()
$config->increment('foo', 1);
$this->assertEquals(27, $config['foo']);
}
+
+ public function test_delete()
+ {
+ $config = new phpbb_config(array('foo' => 'bar'));
+
+ $config->delete('foo');
+ $this->assertFalse(isset($config['foo']));
+ }
}
View
14 tests/config/db_test.php
@@ -125,4 +125,18 @@ public function test_increment_new()
$this->config->increment('foobar', 3);
$this->assertEquals(3, $this->config['foobar']);;
}
+
+ public function test_delete()
+ {
+ $this->assertTrue(isset($this->config['foo']));
+ $this->config->delete('foo');
+ $this->cache->checkVarUnset($this, 'foo');
+ $this->assertFalse(isset($this->config['foo']));
+
+ // re-read config and populate cache
+ $cache2 = new phpbb_mock_cache;
+ $config2 = new phpbb_config_db($this->db, $cache2, 'phpbb_config');
+ $cache2->checkVarUnset($this, 'foo');
+ $this->assertFalse(isset($config2['foo']));
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.