From ba0aef4f3016f95392c96e7ebd579b2aecb5c5c0 Mon Sep 17 00:00:00 2001 From: jgen Date: Sat, 22 Feb 2014 00:40:14 -0500 Subject: [PATCH] The Database class should really throw an error here. This will likely break the existing tests. --- core/database.class.php | 22 ++++++++++++++++------ ext/alias_editor/test.php | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index 67237c1b..641bfe76 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -361,16 +361,26 @@ class Database { } public function commit() { - if(!is_null($this->db) && $this->transaction === true) { - $this->transaction = false; - return $this->db->commit(); + if(!is_null($this->db)) { + if ($this->transaction === true) { + $this->transaction = false; + return $this->db->commit(); + } + else { + throw new SCoreException("

Database Transaction Error: Unable to call commit() as there is no transaction currently open."); + } } } public function rollback() { - if(!is_null($this->db) && $this->transaction === true) { - $this->transaction = false; - return $this->db->rollback(); + if(!is_null($this->db)) { + if ($this->transaction === true) { + $this->transaction = false; + return $this->db->rollback(); + } + else { + throw new SCoreException("

Database Transaction Error: Unable to call rollback() as there is no transaction currently open."); + } } } diff --git a/ext/alias_editor/test.php b/ext/alias_editor/test.php index c67c52cf..efb03d9a 100644 --- a/ext/alias_editor/test.php +++ b/ext/alias_editor/test.php @@ -19,6 +19,7 @@ class AliasEditorTest extends ShimmieWebTestCase { $this->set_field('oldtag', "test1"); $this->set_field('newtag', "test2"); $this->click("Add"); + $this->assert_no_text("Error adding alias"); $this->get_page('alias/list'); $this->assert_text("test1");