diff --git a/interdiff.diff b/interdiff.diff index 6dfcb58..07a5a28 100644 --- a/interdiff.diff +++ b/interdiff.diff @@ -25,7 +25,7 @@ index 6590aa8..b121815 100644 // Make sure a new node gets a new menu link. if (empty($node->nid)) { diff --git a/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php b/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php -index 947db2d..c80e003 100644 +index 2634041..dcd4b14 100644 --- a/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php +++ b/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php @@ -9,6 +9,7 @@ namespace Drupal\entity; @@ -73,13 +73,13 @@ index 947db2d..c80e003 100644 } /** -+ * Saves a node revision. ++ * Saves an entity revision. + * -+ * @param Drupal\entity\EntityInterface $node -+ * The node entity. ++ * @param Drupal\entity\StorableInterface $entity ++ * The entity object. + */ -+ protected function saveRevision(EntityInterface $entity) { -+ // Convert the entity into a array as it might not have the same properties ++ protected function saveRevision(StorableInterface $entity) { ++ // Convert the entity into an array as it might not have the same properties + // as the entity, it is just a raw structure. + $record = (array) $entity; + @@ -122,20 +122,20 @@ index 947db2d..c80e003 100644 + * + * @param array $record + * The revision array. -+ * @param Drupal\entity\EntityInterface $entity ++ * @param Drupal\entity\StorableInterface $entity + * The entity object. + */ -+ protected function preSaveRevision(array &$record, EntityInterface $entity) { } ++ protected function preSaveRevision(array &$record, StorableInterface $entity) { } + + /** * Invokes a hook on behalf of the entity. * * @param $hook -diff --git a/core/modules/entity/lib/Drupal/entity/Entity.php b/core/modules/entity/lib/Drupal/entity/Entity.php -index 2055336..88c1b5f 100644 ---- a/core/modules/entity/lib/Drupal/entity/Entity.php -+++ b/core/modules/entity/lib/Drupal/entity/Entity.php -@@ -41,6 +41,13 @@ class Entity implements EntityInterface { +diff --git a/core/modules/entity/lib/Drupal/entity/StorableBase.php b/core/modules/entity/lib/Drupal/entity/StorableBase.php +index 57bf352..af23fa8 100644 +--- a/core/modules/entity/lib/Drupal/entity/StorableBase.php ++++ b/core/modules/entity/lib/Drupal/entity/StorableBase.php +@@ -41,6 +41,13 @@ abstract class StorableBase implements StorableInterface { protected $enforceIsNew; /** @@ -149,11 +149,11 @@ index 2055336..88c1b5f 100644 * Indicates whether this is the current revision. * * @var bool -@@ -80,6 +87,14 @@ class Entity implements EntityInterface { +@@ -80,6 +87,14 @@ abstract class StorableBase implements StorableInterface { } /** -+ * Implements EntityInterface::isNewRevision(). ++ * Implements StorableInterface::isNewRevision(). + */ + public function isNewRevision() { + $info = $this->entityInfo(); @@ -161,37 +161,37 @@ index 2055336..88c1b5f 100644 + } + + /** - * Implements EntityInterface::enforceIsNew(). + * Implements StorableInterface::enforceIsNew(). */ public function enforceIsNew($value = TRUE) { -@@ -87,6 +102,13 @@ class Entity implements EntityInterface { +@@ -87,6 +102,13 @@ abstract class StorableBase implements StorableInterface { } /** -+ * Implements EntityInterface::enforceIsNewRevision(). ++ * Implements StorableInterface::setNewRevision(). + */ + public function setNewRevision($value = TRUE) { + $this->newRevision = $value; + } + + /** - * Implements EntityInterface::entityType(). + * Implements StorableInterface::entityType(). */ public function entityType() { -diff --git a/core/modules/entity/lib/Drupal/entity/EntityInterface.php b/core/modules/entity/lib/Drupal/entity/EntityInterface.php -index ef95cc2..043c2cf 100644 ---- a/core/modules/entity/lib/Drupal/entity/EntityInterface.php -+++ b/core/modules/entity/lib/Drupal/entity/EntityInterface.php -@@ -57,6 +57,26 @@ interface EntityInterface { +diff --git a/core/modules/entity/lib/Drupal/entity/StorableInterface.php b/core/modules/entity/lib/Drupal/entity/StorableInterface.php +index 820fdc7..ad96986 100644 +--- a/core/modules/entity/lib/Drupal/entity/StorableInterface.php ++++ b/core/modules/entity/lib/Drupal/entity/StorableInterface.php +@@ -57,6 +57,26 @@ interface StorableInterface { public function isNew(); /** + * Returns whether a new revisions should be created on save. + * -+ * @return ++ * @return bool + * TRUE if a new revision should be created. + * -+ * @see Drupal\entity\EntityInterface::newRevision() ++ * @see Drupal\entity\StorableInterface::newRevision() + */ + public function isNewRevision(); + @@ -201,7 +201,7 @@ index ef95cc2..043c2cf 100644 + * @param bool $value + * (optional) Whether a new revision should be saved. + * -+ * @see Drupal\entity\EntityInterface::isNewRevision() ++ * @see Drupal\entity\StorableInterface::isNewRevision() + */ + public function setNewRevision($value = TRUE); + @@ -238,7 +238,7 @@ index 535e45d..03cff3b 100644 } diff --git a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php -index 8021673..e17678f 100644 +index 8021673..693e599 100644 --- a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php @@ -48,13 +48,15 @@ class BulkDeleteTest extends FieldTestBase { @@ -253,7 +253,7 @@ index 8021673..e17678f 100644 - unset($partial_entities[$id]->ftlabel); - $partial_entities[$id]->enforceIsNew(NULL); + // Re-create the entity to match what is expected -+ // _field_create_entity_from_ids(). ++ // _field_create_entity_from_ids(). + $ids = (object) array( + 'entity_id' => $entity->ftid, + 'revision_id' => $entity->ftvid, @@ -280,18 +280,23 @@ index 0a612e8..4344d21 100644 $web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content')); $this->drupalLogin($web_user); diff --git a/core/modules/field/modules/options/tests/options_test.module b/core/modules/field/modules/options/tests/options_test.module -index 604205b..e21b376 100644 +index 604205b..2f92a66 100644 --- a/core/modules/field/modules/options/tests/options_test.module +++ b/core/modules/field/modules/options/tests/options_test.module -@@ -28,5 +28,5 @@ function options_test_allowed_values_callback($field, $instance, $entity_type, $ +@@ -28,5 +28,10 @@ function options_test_allowed_values_callback($field, $instance, $entity_type, $ function options_test_dynamic_values_callback($field, $instance, $entity_type, $entity, &$cacheable) { $cacheable = FALSE; // We need the values of the entity as keys. - return drupal_map_assoc(array_merge(array($entity->ftlabel), array($entity->id(), $entity->getRevisionId(), $entity->bundle()))); -+ return drupal_map_assoc(array($entity->ftlabel, $entity->id(), $entity->getRevisionId(), $entity->bundle())); ++ return drupal_map_assoc(array( ++ $entity->ftlabel, ++ $entity->id(), ++ $entity->getRevisionId(), ++ $entity->bundle(), ++ )); } diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc -index 9283bfe..aed74c2 100644 +index 9283bfe..ec3309c 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -233,6 +233,8 @@ function field_test_create_entity($id = 1, $vid = 1, $bundle = 'test_bundle', $l @@ -323,12 +328,13 @@ index 9283bfe..aed74c2 100644 $message = $insert ? t('test_entity @id has been created.', array('@id' => $entity->ftid)) : t('test_entity @id has been updated.', array('@id' => $entity->ftid)); drupal_set_message($message); -@@ -362,6 +368,8 @@ function field_test_entity_form_submit($form, &$form_state) { +@@ -362,6 +368,9 @@ function field_test_entity_form_submit($form, &$form_state) { /** * Updates the form state's entity by processing this submission's values. + * + * @return Drupal\field_test\TestEntity ++ * Updated entity. */ function field_test_entity_form_submit_build_test_entity($form, &$form_state) { $entity = $form_state['test_entity']; @@ -351,22 +357,22 @@ index fb1335b..a29e23a 100644 */ public function id() { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntityController.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntityController.php -index 3bdab77..20c3029 100644 +index 49129ca..5e7a00e 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntityController.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntityController.php -@@ -16,37 +16,12 @@ use Drupal\entity\EntityInterface; +@@ -16,37 +16,12 @@ use Drupal\entity\StorableInterface; class TestEntityController extends DatabaseStorageController { /** - * Overrides Drupal\entity\DatabaseStorageController::preSave(). + * Overrides Drupal\entity\DatabaseStorageController::preSaveRevision(). */ -- public function preSave(EntityInterface $entity) { +- public function preSave(StorableInterface $entity) { - // Prepare for a new revision. - if (!$entity->isNew() && !empty($entity->revision)) { - $entity->old_ftvid = $entity->ftvid; - $entity->ftvid = NULL; -+ public function preSaveRevision(array &$record, EntityInterface $entity) { ++ public function preSaveRevision(array &$record, StorableInterface $entity) { + // Allow for predefined revision ids. + if (!empty($record['use_provided_revision_id'])) { + $record['ftvid'] = $record['use_provided_revision_id']; @@ -376,7 +382,7 @@ index 3bdab77..20c3029 100644 - /** - * Overrides Drupal\entity\DatabaseStorageController::postSave(). - */ -- public function postSave(EntityInterface $entity, $update) { +- public function postSave(StorableInterface $entity, $update) { - // Only the test_entity entity type has revisions. - if ($entity->entityType() == 'test_entity') { - $update_entity = TRUE; @@ -426,7 +432,7 @@ index 30b1e6b..e511263 100644 db_update('forum') ->fields(array('tid' => $node->forum_tid)) diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php -index c5763e8..1b687d2 100644 +index c5763e8..3932a4f 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -44,7 +44,7 @@ class NodeFormController extends EntityFormController { @@ -438,11 +444,13 @@ index c5763e8..1b687d2 100644 node_invoke($node, 'prepare'); module_invoke_all('node_prepare', $node); -@@ -117,7 +117,7 @@ class NodeFormController extends EntityFormController { +@@ -116,8 +116,8 @@ class NodeFormController extends EntityFormController { + '#type' => 'fieldset', '#title' => t('Revision information'), '#collapsible' => TRUE, - // Collapsed by default when "Create new revision" is unchecked +- // Collapsed by default when "Create new revision" is unchecked - '#collapsed' => !$node->revision, ++ // Collapsed by default when "Create new revision" is unchecked. + '#collapsed' => !$node->isNewRevision(), '#group' => 'additional_settings', '#attributes' => array( @@ -484,13 +492,13 @@ index c5763e8..1b687d2 100644 foreach (module_implements('node_submit') as $module) { $function = $module . '_node_submit'; diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php -index d4968a6..05f7b88 100644 +index ee47546..d6ca8d1 100644 --- a/core/modules/node/lib/Drupal/node/NodeStorageController.php +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php @@ -9,8 +9,6 @@ namespace Drupal\node; use Drupal\entity\DatabaseStorageController; - use Drupal\entity\EntityInterface; + use Drupal\entity\StorableInterface; -use Drupal\entity\EntityStorageException; -use Exception; @@ -547,7 +555,7 @@ index d4968a6..05f7b88 100644 - /** - * Overrides Drupal\entity\DatabaseStorageController::save(). - */ -- public function save(EntityInterface $entity) { +- public function save(StorableInterface $entity) { - $transaction = db_transaction(); - try { - // Load the stored entity, if any. @@ -594,10 +602,10 @@ index d4968a6..05f7b88 100644 - /** - * Saves a node revision. - * -- * @param Drupal\entity\EntityInterface $node +- * @param Drupal\entity\StorableInterface $node - * The node entity. - */ -- protected function saveRevision(EntityInterface $entity) { +- protected function saveRevision(StorableInterface $entity) { - $record = clone $entity; - $record->uid = $entity->revision_uid; - $record->timestamp = $entity->revision_timestamp; @@ -616,7 +624,7 @@ index d4968a6..05f7b88 100644 - $entity->{$this->revisionKey} = $record->{$this->revisionKey}; - - // Mark this revision as the current one. -- $entity->isCurrentRevision = TRUE; +- $entity->isCurrentRevision(TRUE); - } - - /** @@ -664,7 +672,7 @@ index d4968a6..05f7b88 100644 /** @@ -249,14 +94,39 @@ class NodeStorageController extends DatabaseStorageController { - protected function preSave(EntityInterface $node) { + protected function preSave(StorableInterface $node) { // Before saving the node, set changed and revision times. $node->changed = REQUEST_TIME; + } @@ -677,7 +685,7 @@ index d4968a6..05f7b88 100644 + /** + * Overrides Drupal\entity\DatabaseStorageController::preSaveRevision(). + */ -+ protected function preSaveRevision(array &$record, EntityInterface $entity) { ++ protected function preSaveRevision(array &$record, StorableInterface $entity) { + if ($entity->isNewRevision()) { + // When inserting either a new node or a new node revision, $node->log + // must be set because {node_revision}.log is a text column and therefore