diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-01 22:03:29 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-01 22:03:29 +0000 |
commit | 3858e1a19f9b8331d01cc7ab45d28b5575c0e260 (patch) | |
tree | c55ae9c4a8216b8ecade83c7b5328cf1ee9d2c7d | |
parent | 7f5caaacdca6de4876ee876a9d1de5ce97ea0c93 (diff) | |
download | brdo-3858e1a19f9b8331d01cc7ab45d28b5575c0e260.tar.gz brdo-3858e1a19f9b8331d01cc7ab45d28b5575c0e260.tar.bz2 |
#926794 by ksenzee, moshe weitzman, Jody Lynn: Fixed revisions of unpublished nodes lose their body field on upgrade.
-rw-r--r-- | modules/node/node.install | 6 | ||||
-rw-r--r-- | modules/simpletest/tests/upgrade/upgrade.node.test | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/modules/node/node.install b/modules/node/node.install index 56af7bce3..5f93db2e8 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -598,7 +598,7 @@ function node_update_7006(&$sandbox) { $sandbox['count'] = 0; $query = db_select('node', 'n'); - $query->join('node_revision', 'nr', 'n.vid = nr.vid'); + $query->join('node_revision', 'nr', 'n.nid = nr.nid'); $sandbox['total'] = $query->countQuery()->execute()->fetchField(); $sandbox['body_field_id'] = $body_field['id']; @@ -611,7 +611,7 @@ function node_update_7006(&$sandbox) { // Operate on every revision of every node (whee!), in batches. $batch_size = 200; $query = db_select('node_revision', 'nr'); - $query->innerJoin('node', 'n', 'n.vid = nr.vid'); + $query->innerJoin('node', 'n', 'n.nid = nr.nid'); $query ->fields('nr', array('nid', 'vid', 'body', 'teaser', 'format')) ->fields('n', array('type', 'status', 'comment', 'promote', 'sticky', 'language')) @@ -620,7 +620,7 @@ function node_update_7006(&$sandbox) { ->range(0, $batch_size); $revisions = $query->execute(); - // Load each reversion of each node, set up 'body' + // Load each revision of each node, set up 'body' // appropriately, and save the node's field data. Note that // node_load() will not return the body or teaser values from // {node_revision} because those columns have been removed from the diff --git a/modules/simpletest/tests/upgrade/upgrade.node.test b/modules/simpletest/tests/upgrade/upgrade.node.test index f5cb3dffb..08617a956 100644 --- a/modules/simpletest/tests/upgrade/upgrade.node.test +++ b/modules/simpletest/tests/upgrade/upgrade.node.test @@ -26,10 +26,19 @@ class NodeBodyUpgradePathTestCase extends UpgradePathTestCase { /** * Test a successful upgrade. */ - public function testNodyBodyUpgrade() { + public function testNodeBodyUpgrade() { $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.')); $this->drupalGet("content/1263769200"); $this->assertText('node body (broken) - 37'); + + // Find a published node revision and make sure it still has a body. + $revision = db_query_range("SELECT r.nid, r.vid FROM {node_revision} r JOIN {node} n ON n.nid = r.nid WHERE n.status = 1 AND n.type <> 'poll' AND n.vid <> r.vid", 0, 1)->fetch(); + $revision = node_load($revision->nid, $revision->vid); + $this->assertTrue(!empty($revision->body), 'Non-current node revisions still have a node body.'); + // Find an unpublished node revision and make sure it still has a body. + $revision = db_query_range("SELECT r.nid, r.vid FROM {node_revision} r JOIN {node} n ON n.nid = r.nid WHERE n.status = 0 AND n.type <> 'poll' AND n.vid <> r.vid", 0, 1)->fetch(); + $revision = node_load($revision->nid, $revision->vid); + $this->assertTrue(!empty($revision->body), 'Unpublished non-current node revisions still have a node body.'); } } |