From 2f67ade05a426d41c95c146a86251d388c718b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 24 Jan 2011 15:13:15 +0100 Subject: [ticket/10006] Add phpbb_config::delete Add the missing `phpbb_config::delete` method to the config class PHPBB3-10006 --- phpBB/includes/config/config.php | 20 ++++++++++++++++++++ phpBB/includes/config/db.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index 64fef28cfa..9596b1e15b 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -103,6 +103,26 @@ 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 bool True if the configuration entry was deleted successfully, + * otherwise false + */ + public function delete($key, $cache = true) + { + if (!isset($this->config[$key])) + { + return false; + } + + unset($this->config[$key]); + return true; + } + /** * Sets a configuration option's value * diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index 74fb0504ce..f0c9a5d591 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -90,6 +90,38 @@ 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 bool True if the configuration entry was deleted successfully, + * otherwise false + */ + public function delete($key, $cache = true) + { + if (!isset($this->config[$key])) + { + return false; + } + + $sql = 'DELETE FROM ' . $this->table . " + WHERE config_name = '" . $this->db->sql_escape($key) . "'"; + $this->db->sql_query($sql); + if (!$this->db->sql_affectedrows()) + { + return false; + } + + unset($this->config[$key]); + + if ($cache) + { + $this->cache->destroy('config'); + } + } + /** * Sets a configuration option's value * -- cgit v1.2.1 From f93ac340a298dae9f45d99ea2b418532942bd423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 24 Jan 2011 16:43:09 +0100 Subject: [ticket/10006] Remove return values Remove some unneeded return values PHPBB3-10006 --- phpBB/includes/config/config.php | 6 ++---- phpBB/includes/config/db.php | 9 ++------- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index 9596b1e15b..ff352abe84 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -109,18 +109,16 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable * @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 bool True if the configuration entry was deleted successfully, - * otherwise false + * @return void */ public function delete($key, $cache = true) { if (!isset($this->config[$key])) { - return false; + return; } unset($this->config[$key]); - return true; } /** diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index f0c9a5d591..caa2cff7f1 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -96,23 +96,18 @@ class phpbb_config_db extends phpbb_config * @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 bool True if the configuration entry was deleted successfully, - * otherwise false + * @return void */ public function delete($key, $cache = true) { if (!isset($this->config[$key])) { - return false; + return; } $sql = 'DELETE FROM ' . $this->table . " WHERE config_name = '" . $this->db->sql_escape($key) . "'"; $this->db->sql_query($sql); - if (!$this->db->sql_affectedrows()) - { - return false; - } unset($this->config[$key]); -- cgit v1.2.1 From 27bbfde2437302ec0b7848513eb15cb91c8e07ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 24 Jan 2011 22:35:42 +0100 Subject: [ticket/10006] Remove unneeded if statements Remove some of the additional `if (isset)` checks PHPBB3-10006 --- phpBB/includes/config/config.php | 5 ----- phpBB/includes/config/db.php | 5 ----- 2 files changed, 10 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index ff352abe84..4ba05a98ec 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -113,11 +113,6 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable */ public function delete($key, $cache = true) { - if (!isset($this->config[$key])) - { - return; - } - unset($this->config[$key]); } diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index caa2cff7f1..f98056e013 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -100,11 +100,6 @@ class phpbb_config_db extends phpbb_config */ public function delete($key, $cache = true) { - if (!isset($this->config[$key])) - { - return; - } - $sql = 'DELETE FROM ' . $this->table . " WHERE config_name = '" . $this->db->sql_escape($key) . "'"; $this->db->sql_query($sql); -- cgit v1.2.1