summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-04-13 23:16:56 +0000
committerDries Buytaert <dries@buytaert.net>2010-04-13 23:16:56 +0000
commit28fb603ae34c22ef10739a4f1f2500125985e51e (patch)
tree9330da3713c613c0345f36e5d3644fddd1011274
parentd6217df82fc964d59b59e7f9a7bd88f5615ac0a2 (diff)
downloadbrdo-28fb603ae34c22ef10739a4f1f2500125985e51e.tar.gz
brdo-28fb603ae34c22ef10739a4f1f2500125985e51e.tar.bz2
- Patch #704646 by cha0s, jpmckinney, willmoy, mradcliffe: critical bug: node_save() fails silently.
-rw-r--r--modules/node/node.module1
-rw-r--r--modules/node/node.test26
2 files changed, 19 insertions, 8 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index d9c137996..4de3f342e 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1094,6 +1094,7 @@ function node_save($node) {
}
catch (Exception $e) {
$transaction->rollback('node', $e->getMessage(), array(), WATCHDOG_ERROR);
+ throw $e;
}
}
diff --git a/modules/node/node.test b/modules/node/node.test
index a97501f3f..ac8c9fc8a 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -427,7 +427,7 @@ class NodeCreationTestCase extends DrupalWebTestCase {
}
function setUp() {
- // Enable dummy module that implements hook_node_post_save for exceptions.
+ // Enable dummy module that implements hook_node_insert for exceptions.
parent::setUp('node_test_exception');
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content'));
@@ -458,20 +458,30 @@ class NodeCreationTestCase extends DrupalWebTestCase {
*/
function testFailedPageCreation() {
// Create a node.
- $edit = array();
- $langcode = LANGUAGE_NONE;
- $edit["title"] = 'testing_transaction_exception';
- $edit["body[$langcode][0][value]"] = $this->randomName(16);
- $this->drupalPost('node/add/page', $edit, t('Save'));
+ $edit = array(
+ 'uid' => $this->loggedInUser->uid,
+ 'name' => $this->loggedInUser->name,
+ 'type' => 'page',
+ 'language' => LANGUAGE_NONE,
+ 'title' => 'testing_transaction_exception',
+ );
+
+ try {
+ node_save((object) $edit);
+ $this->fail(t('Expected exception has not been thrown.'));
+ }
+ catch (Exception $e) {
+ $this->pass(t('Expected exception has been thrown.'));
+ }
if (Database::getConnection()->supportsTransactions()) {
// Check that the node does not exist in the database.
- $node = $this->drupalGetNodeByTitle($edit["title"]);
+ $node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertFalse($node, t('Transactions supported, and node not found in database.'));
}
else {
// Check that the node exists in the database.
- $node = $this->drupalGetNodeByTitle($edit["title"]);
+ $node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertTrue($node, t('Transactions not supported, and node found in database.'));
// Check that the failed rollback was logged.