diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index 4340882..f1b4979 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -530,4 +530,23 @@ public function label($langcode = NULL) { return $label; } + /** + * Overrides Entity::isNewRevision(). + */ + public function isNewRevision() { + $info = $this->entityInfo(); + return $this->newRevision->value || (!empty($info['entity_keys']['revision']) && !$this->getRevisionId()); + } + + /** + * Overrides Entity::isDefaultRevision(). + */ + public function isDefaultRevision($new_value = NULL) { + $return = $this->isDefaultRevision->value; + if (isset($new_value)) { + $this->isDefaultRevision = (bool) $new_value; + } + return $return; + } + } diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php index a4a758d..31f9f32 100644 --- a/core/modules/node/lib/Drupal/node/NodeStorageController.php +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php @@ -313,6 +313,11 @@ public function baseFieldDefinitions() { 'settings' => array('target_type' => 'user'), 'queryable' => FALSE, ); + $properties['log'] = array( + 'label' => t('Log'), + 'description' => t('The log entry explaining the changes in this version.'), + 'type' => 'text_field', + ); return $properties; } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php index 9a43fae..35beff1 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php @@ -214,6 +214,7 @@ protected function init() { unset($this->translate); unset($this->revision_timestamp); unset($this->revision_uid); + unset($this->log); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php index 655c4c1..4703d11 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php @@ -48,18 +48,24 @@ function setUp() { $logs = array(); // Get the original node. - $nodes[] = $node; + $nodes[] = clone $node; // Create three revisions. $revision_count = 3; for ($i = 0; $i < $revision_count; $i++) { - $logs[] = $settings['log'] = $this->randomName(32); + $logs[] = $node->log = $this->randomName(32); // Create revision with a random title and body and update variables. - $this->drupalCreateNode($settings); + $node->title = $this->randomName(); + $node->body[$node->language()->langcode][0] = array( + 'value' => $this->randomName(32), + 'format' => filter_default_format(), + ); + $node->setNewRevision(); + $node->save(); + $node = node_load($node->nid); // Make sure we get revision information. - $settings = get_object_vars($node); - $nodes[] = $node; + $nodes[] = clone $node; } $this->nodes = $nodes; @@ -110,7 +116,7 @@ function testRevisions() { '%revision-date' => format_date($nodes[1]->revision_timestamp) )), 'Revision reverted.'); - $reverted_node = node_load($node->nid); + $reverted_node = node_load($node->nid, TRUE); $this->assertTrue(($nodes[1]->body[LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[LANGUAGE_NOT_SPECIFIED][0]['value']), t('Node reverted correctly.')); // Confirm that this is not the current version.