mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-25 04:23:38 +01:00
Merge branch 'ticket/erikfrerejean/10006' into develop
This commit is contained in:
commit
8fe75aefbb
@ -103,6 +103,19 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable
|
||||
return count($this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
@ -90,6 +90,28 @@ class phpbb_config_db extends phpbb_config
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
@ -109,4 +109,12 @@ class phpbb_config_test extends phpbb_test_case
|
||||
$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']));
|
||||
}
|
||||
}
|
||||
|
@ -125,4 +125,18 @@ class phpbb_config_db_test extends phpbb_database_test_case
|
||||
$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']));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user