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') 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