diff --git a/src/mibew/libs/classes/Mibew/Database.php b/src/mibew/libs/classes/Mibew/Database.php index c2508265..77bee3ef 100644 --- a/src/mibew/libs/classes/Mibew/Database.php +++ b/src/mibew/libs/classes/Mibew/Database.php @@ -101,7 +101,7 @@ class Database * Controls if exception must be processed into class or thrown * @var boolean */ - protected $throwExceptions = false; + protected $useExceptions = false; /** * Get instance of Database class. @@ -209,14 +209,37 @@ class Database * If called without arguments just return previous value without changing * anything. * - * @param boolean $value Value that should be set. This argument is optional + * There is a typo in the method name. One should use + * {@link Database::throwExceptions()} method instead. + * + * @deprecated since version 2.0.0 + * @param boolean|null $value Value that should be set. This argument is + * optional and can be skipped (or set to null) to keep the internal value + * unchanged. * @return bool Previous value */ - public function throwExeptions() + public function throwExeptions($value = null) { - $last_value = $this->throwExceptions; - if (func_num_args() > 0) { - $this->throwExceptions = func_get_arg(0); + return $this->throwExceptions($value); + } + + /** + * Set if exceptions must be process into the class or thrown and return + * previous value. + * + * If called without arguments just return previous value without changing + * anything. + * + * @param boolean|null $value Value that should be set. This argument is + * optional and can be skipped (or set to null) to keep the internal value + * unchanged. + * @return bool Previous value + */ + public function throwExceptions($value = null) + { + $last_value = $this->useExceptions; + if (!is_null($value)) { + $this->useExceptions = $value; } return $last_value; @@ -400,7 +423,7 @@ class Database */ protected function handleError(\Exception $e) { - if ($this->throwExceptions) { + if ($this->useExceptions) { throw $e; } die($e->getMessage()); diff --git a/src/mibew/libs/classes/Mibew/Maintenance/Installer.php b/src/mibew/libs/classes/Mibew/Maintenance/Installer.php index 2a608e6a..99e38ad2 100644 --- a/src/mibew/libs/classes/Mibew/Maintenance/Installer.php +++ b/src/mibew/libs/classes/Mibew/Maintenance/Installer.php @@ -787,7 +787,7 @@ class Installer } $db = Database::getInstance(); - $db->throwExeptions(true); + $db->throwExceptions(true); return $db; } diff --git a/src/mibew/libs/classes/Mibew/Maintenance/Updater.php b/src/mibew/libs/classes/Mibew/Maintenance/Updater.php index 1172d1d0..9cd591e7 100644 --- a/src/mibew/libs/classes/Mibew/Maintenance/Updater.php +++ b/src/mibew/libs/classes/Mibew/Maintenance/Updater.php @@ -185,7 +185,7 @@ class Updater { try { $db = Database::getInstance(); - $db->throwExeptions(true); + $db->throwExceptions(true); return $db; } catch (\Exception $e) { diff --git a/src/mibew/libs/statistics.php b/src/mibew/libs/statistics.php index 2e0dade3..8d33e8b8 100644 --- a/src/mibew/libs/statistics.php +++ b/src/mibew/libs/statistics.php @@ -164,7 +164,7 @@ function calculate_thread_statistics() { // Prepare database $db = Database::getInstance(); - $db_throw_exceptions = $db->throwExeptions(true); + $db_throw_exceptions = $db->throwExceptions(true); try { // Start transaction @@ -379,7 +379,7 @@ function calculate_thread_statistics() $db->query('ROLLBACK'); // Set throw exceptions back - $db->throwExeptions($db_throw_exceptions); + $db->throwExceptions($db_throw_exceptions); return; } @@ -388,7 +388,7 @@ function calculate_thread_statistics() $db->query('COMMIT'); // Set throw exceptions back - $db->throwExeptions($db_throw_exceptions); + $db->throwExceptions($db_throw_exceptions); } /** @@ -398,7 +398,7 @@ function calculate_operator_statistics() { // Prepare database $db = Database::getInstance(); - $db_throw_exceptions = $db->throwExeptions(true); + $db_throw_exceptions = $db->throwExceptions(true); try { // Start transaction @@ -536,7 +536,7 @@ function calculate_operator_statistics() $db->query('ROLLBACK'); // Set throw exceptions back - $db->throwExeptions($db_throw_exceptions); + $db->throwExceptions($db_throw_exceptions); return; } @@ -545,7 +545,7 @@ function calculate_operator_statistics() $db->query('COMMIT'); // Set throw exceptions back - $db->throwExeptions($db_throw_exceptions); + $db->throwExceptions($db_throw_exceptions); } /** @@ -555,7 +555,7 @@ function calculate_page_statistics() { // Prepare database $db = Database::getInstance(); - $db_throw_exceptions = $db->throwExeptions(true); + $db_throw_exceptions = $db->throwExceptions(true); try { // Start transaction @@ -791,7 +791,7 @@ function calculate_page_statistics() $db->query('ROLLBACK'); // Set throw exceptions back - $db->throwExeptions($db_throw_exceptions); + $db->throwExceptions($db_throw_exceptions); return; } @@ -800,7 +800,7 @@ function calculate_page_statistics() $db->query('COMMIT'); // Set throw exceptions back - $db->throwExeptions($db_throw_exceptions); + $db->throwExceptions($db_throw_exceptions); } /**