From c900b5f637287ac59ffbeab82b67aebb9de9d846 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 19 Sep 2014 12:24:08 +0200 Subject: [PATCH] Fixed benchmark not stopping on database exceptions Fixes #1788 --- .../database/statement/PreparedStatement.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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); } } -- 2.20.1