Fixed benchmark not stopping on database exceptions
authorAlexander Ebert <ebert@woltlab.com>
Fri, 19 Sep 2014 10:24:08 +0000 (12:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 19 Sep 2014 10:24:08 +0000 (12:24 +0200)
Fixes #1788

wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php

index edf6467e6a095f631f62f8997bca37bdbd10702a..03bb33abbba28b5179dd3fba9bf793f9003389ba 100644 (file)
@@ -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);
                }
        }