From 26acd8a5e43f6fc697728f04f4966b26bbd05230 Mon Sep 17 00:00:00 2001 From: Vishal Pandey Date: Tue, 14 Mar 2017 00:57:28 +0530 Subject: [ticket/11515] Extra check after acquiring locks. Add additional check to flock.php and db.php to ensure lock aquiring. PHPBB3-11515 --- phpBB/phpbb/config/config.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpBB/phpbb/config/config.php') diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php index aaad333006..036ae32cef 100644 --- a/phpBB/phpbb/config/config.php +++ b/phpBB/phpbb/config/config.php @@ -147,6 +147,27 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable return false; } + /** + * Checks configuration option's value only if the new_value matches the + * current configuration value and the configuration value does exist.Called + *only after set_atomic has been called. + * + * @param string $key The configuration option's name + * @param string $old_value Current configuration value + * @param string $new_value New configuration value + * @throws \phpbb\exception\http_exception when configuration value is set and not equal to *new_value. + * @return bool True if the value was changed, false otherwise. + */ + public function ensure_lock($key, $new_value) + { + if(isset($this->config[$key]) && $this->config[$key] == $new_value) + { + return true; + } else { + throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.'); + } + } + /** * Increments an integer configuration value. * -- cgit v1.2.1 From 530e5bca87758342bfe0f212191ace8a709bdb75 Mon Sep 17 00:00:00 2001 From: Vishal Pandey Date: Tue, 14 Mar 2017 02:16:18 +0530 Subject: [ticket/11515] Change If...else statement struct Modifications in if-else structure. PHPBB3-11515 --- phpBB/phpbb/config/config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/config/config.php') diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php index 036ae32cef..239e4c2e55 100644 --- a/phpBB/phpbb/config/config.php +++ b/phpBB/phpbb/config/config.php @@ -163,7 +163,9 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable if(isset($this->config[$key]) && $this->config[$key] == $new_value) { return true; - } else { + } + else + { throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.'); } } -- cgit v1.2.1 From cf12223b25ebba131ce2cbe407227ed6abffa949 Mon Sep 17 00:00:00 2001 From: Vishal Pandey Date: Tue, 14 Mar 2017 02:27:18 +0530 Subject: [ticket/11515] Space between if and braces Exactly one space between if and opening brace. PHPBB3-11515 --- phpBB/phpbb/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/config/config.php') diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php index 239e4c2e55..0a867342f5 100644 --- a/phpBB/phpbb/config/config.php +++ b/phpBB/phpbb/config/config.php @@ -160,7 +160,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable */ public function ensure_lock($key, $new_value) { - if(isset($this->config[$key]) && $this->config[$key] == $new_value) + if (isset($this->config[$key]) && $this->config[$key] == $new_value) { return true; } -- cgit v1.2.1 From 7d4909dc064b46022020234c7316c86fc0d38a69 Mon Sep 17 00:00:00 2001 From: Vishal Pandey Date: Tue, 14 Mar 2017 17:19:41 +0530 Subject: [ticket/11515] Refactoring the patch. Removing else conditions. PHPBB3-11515 --- phpBB/phpbb/config/config.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'phpBB/phpbb/config/config.php') diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php index 0a867342f5..f4b670e834 100644 --- a/phpBB/phpbb/config/config.php +++ b/phpBB/phpbb/config/config.php @@ -164,10 +164,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable { return true; } - else - { - throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.'); - } + throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.'); } /** -- cgit v1.2.1 From f1c2f7baae0da3277a2c71f47eed34589b62ba85 Mon Sep 17 00:00:00 2001 From: Vishal Pandey Date: Sat, 18 Mar 2017 22:37:16 +0530 Subject: [ticket/11515] Refactoring changes. Refactoring the code as suggested. PHPBB3-11515 --- phpBB/phpbb/config/config.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/config/config.php') diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php index f4b670e834..c619cae2fd 100644 --- a/phpBB/phpbb/config/config.php +++ b/phpBB/phpbb/config/config.php @@ -150,12 +150,11 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable /** * Checks configuration option's value only if the new_value matches the * current configuration value and the configuration value does exist.Called - *only after set_atomic has been called. + * only after set_atomic has been called. * * @param string $key The configuration option's name - * @param string $old_value Current configuration value * @param string $new_value New configuration value - * @throws \phpbb\exception\http_exception when configuration value is set and not equal to *new_value. + * @throws \phpbb\exception\http_exception when config value is set and not equal to new_value. * @return bool True if the value was changed, false otherwise. */ public function ensure_lock($key, $new_value) -- cgit v1.2.1