Commit 4d8efc4b authored by alexpott's avatar alexpott

Issue #2741249 by Mile23, timmillwood, sneha_surve: Remove entity_revision*...

Issue #2741249 by Mile23, timmillwood, sneha_surve: Remove entity_revision* family of functions usage from the code base
parent fe33c4b9
......@@ -70,7 +70,9 @@ public function testRevisions() {
foreach ($blocks as $delta => $revision_id) {
// Confirm the correct revision text appears.
/** @var \Drupal\block_content\BlockContentInterface $loaded */
$loaded = entity_revision_load('block_content', $revision_id);
$loaded = $this->container->get('entity_type.manager')
->getStorage('block_content')
->loadRevision($revision_id);
// Verify revision log is the same.
$this->assertEqual($loaded->getRevisionLogMessage(), $logs[$delta], format_string('Correct log message found for revision @revision', array(
'@revision' => $loaded->getRevisionId(),
......
......@@ -172,7 +172,7 @@ public function testEditorEntityHooks() {
}
// Test editor_entity_revision_delete(): decrement, by deleting a revision.
entity_revision_delete('node', $second_revision_id);
$this->container->get('entity_type.manager')->getStorage('node')->deleteRevision($second_revision_id);
foreach ($image_entities as $key => $image_entity) {
$this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
}
......
......@@ -575,7 +575,9 @@ function testFieldFormAccess() {
$this->assertEqual($entity->$field_name->value, 2, 'New revision has the expected value for the field with edit access.');
// Check that the revision is also saved in the revisions table.
// $entity = entity_revision_load($entity_type, $entity->getRevisionId());
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->loadRevision($entity->getRevisionId());
$this->assertEqual($entity->$field_name_no_access->value, 99, 'New revision has the expected value for the field with no edit access.');
$this->assertEqual($entity->$field_name->value, 2, 'New revision has the expected value for the field with edit access.');
}
......
......@@ -124,7 +124,9 @@ function testFieldFormTranslationRevisions() {
*/
private function checkTranslationRevisions($id, $revision_id, $available_langcodes) {
$field_name = $this->fieldStorage->getName();
$entity = entity_revision_load($this->entityTypeId, $revision_id);
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
->loadRevision($revision_id);
foreach ($available_langcodes as $langcode => $value) {
$passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1;
$this->assertTrue($passed, format_string('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->getRevisionId())));
......
......@@ -6,7 +6,6 @@
*/
use Drupal\node\NodeInterface;
use Drupal\node\Entity\Node;
/**
* Updates all nodes in the passed-in array with the passed-in field values.
......@@ -51,12 +50,13 @@ function node_mass_update(array $nodes, array $updates, $langcode = NULL, $load
batch_set($batch);
}
else {
$storage = \Drupal::entityTypeManager()->getStorage('node');
if ($load && !$revisions) {
$nodes = Node::loadMultiple($nodes);
$nodes = $storage->loadMultiple($nodes);
}
foreach ($nodes as $node) {
if ($load && $revisions) {
$node = entity_revision_load('node', $node);
$node = $storage->loadRevision($node);
}
_node_mass_update_helper($node, $updates, $langcode);
}
......@@ -122,13 +122,14 @@ function _node_mass_update_batch_process(array $nodes, array $updates, $langcode
}
// Process nodes by groups of 5.
$storage = \Drupal::entityTypeManager()->getStorage('node');
$count = min(5, count($context['sandbox']['nodes']));
for ($i = 1; $i <= $count; $i++) {
// For each nid, load the node, reset the values, and save it.
$node = array_shift($context['sandbox']['nodes']);
if ($load) {
$node = $revisions ?
entity_revision_load('node', $node) : Node::load($node);
$storage->loadRevision($node) : $storage->load($node);
}
$node = _node_mass_update_helper($node, $updates, $langcode);
......
......@@ -457,7 +457,7 @@ function node_load($nid = NULL, $reset = FALSE) {
* A fully-populated node entity, or NULL if the node is not found.
*/
function node_revision_load($vid = NULL) {
return entity_revision_load('node', $vid);
return \Drupal::entityTypeManager()->getStorage('node')->loadRevision($vid);
}
/**
......
......@@ -98,9 +98,10 @@ protected function runRevisionsTests($entity_type) {
$this->assertNotEqual($entity->field_test_text->value, $legacy_text, format_string('%entity_type: Text changed.', array('%entity_type' => $entity_type)));
}
$storage = $this->container->get('entity_type.manager')->getStorage($entity_type);
for ($i = 0; $i < $revision_count; $i++) {
// Load specific revision.
$entity_revision = entity_revision_load($entity_type, $revision_ids[$i]);
$entity_revision = $storage->loadRevision($revision_ids[$i]);
// Check if properties and fields contain the revision specific content.
$this->assertEqual($entity_revision->revision_id->value, $revision_ids[$i], format_string('%entity_type: Revision ID matches.', array('%entity_type' => $entity_type)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment