From: Alexander Ebert Date: Fri, 19 Sep 2014 10:24:08 +0000 (+0200) Subject: Fixed benchmark not stopping on database exceptions X-Git-Tag: 2.1.0_Alpha_1~319 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c900b5f637287ac59ffbeab82b67aebb9de9d846;p=GitHub%2FWoltLab%2FWCF.git Fixed benchmark not stopping on database exceptions Fixes #1788 --- diff --git a/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php b/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php index edf6467e6a..03bb33abbb 100644 --- a/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php +++ b/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php @@ -76,14 +76,12 @@ class PreparedStatement { /** * Executes a prepared statement within a transaction. - * CAUTION: Transactions disabled for now, use manual transaction if you like * * @param array $parameters */ public function execute(array $parameters = array()) { $this->parameters = $parameters; $this->database->incrementQueryCount(); - //$this->database->beginTransaction(); try { if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY); @@ -92,11 +90,10 @@ class PreparedStatement { else $this->pdoStatement->execute($parameters); if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop(); - - //$this->database->commitTransaction(); } catch (\PDOException $e) { - //$this->database->rollBackTransaction(); + if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop(); + throw new DatabaseException('Could not execute prepared statement: '.$e->getMessage(), $this->database, $this); } } @@ -119,6 +116,8 @@ class PreparedStatement { if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop(); } catch (\PDOException $e) { + if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop(); + throw new DatabaseException('Could not execute prepared statement: '.$e->getMessage(), $this->database, $this); } }