Comments

yesct’s picture

Title: Replace all instances of block_content_load(), block_content_load_multiple(), entity_load('block_content') and entity_load_multiple('block_content') with static method calls » Replace all instances of entity_load('block_content') and entity_load_multiple('block_content') with static method calls
mglaman’s picture

Status: Active » Needs review
StatusFileSize
new8.56 KB

Patch with changes.

Status: Needs review » Needs work

The last submitted patch, 2: replace_all_instances-2377113-2.patch, failed testing.

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new8.66 KB

Fix entity cache before checking revision for test.

mglaman’s picture

StatusFileSize
new712 bytes

Attaching interdiff!

yesct’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: -Novice

Thanks for the interdiff. :)

1.
Why did we need to clear the cache using the static load()? and we didn't using the entity_load_multiple()?

+++ b/core/modules/block_content/src/Tests/PageEditTest.php
@@ -55,7 +56,8 @@ public function testPageEdit() {
-    $revised_block = entity_load('block_content', $block->id(), TRUE);
+    \Drupal::entityManager()->getStorage('block_content')->resetCache(array($block->id()));

was that what the TRUE was doing? ah yes. ok.

2.

+++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php
@@ -6,7 +6,7 @@
 namespace Drupal\block_content\Tests;
-
+use Drupal\block_content\Entity\BlockContentType;

This blank line should not have been removed.
We have a blank line between the name space and the block of use statements (although I couldn't find that in the OO white space standards... https://www.drupal.org/node/608152 )

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new8.65 KB
new492 bytes

Correct - you can't call reset within load anymore, so we have to tell the entity storage to reset the entity cache.

Attached updated patch to fix up my screwy line spacing on BlockContentTypeTest.

Status: Needs review » Needs work

The last submitted patch, 7: replace_all_instances-2377113-7.patch, failed testing.

pcambra’s picture

Status: Needs work » Needs review
StatusFileSize
new10.18 KB

Re-rolled and added a couple more loads that were introduced since #7

berdir’s picture

Component: entity system » custom_block.module

Moving this to the right component :) (Which has the wrong name...)

chanderbhushan’s picture

#10 applying successfully

gaurav_varshney’s picture

#10 Patch Applied Successfully

webchick’s picture

Component: custom_block.module » block_content.module
linl’s picture

StatusFileSize
new10.15 KB
new900 bytes

Also noticed a couple of namespace spacing issues.

jeroent’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new10.01 KB
new1.95 KB

Nitpick, sort use statements alphabetical.

jeroent’s picture

Status: Reviewed & tested by the community » Needs review

Go testbot!

jeroent’s picture

Status: Needs review » Reviewed & tested by the community

No occurrences of entity_load('block_content') and entity_load_multiple('block_content') left and tests pass.

Marking as RTBC as the only thing I did was rearrange the use statements.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/block_content/src/BlockContentForm.php
@@ -80,7 +81,7 @@ public static function create(ContainerInterface $container) {
-    $block_type = entity_load('block_content_type', $block->bundle());
+    $block_type = BlockContentType::load($block->bundle());

+++ b/core/modules/block_content/src/BlockContentTranslationHandler.php
@@ -37,7 +38,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
-    $block_type = entity_load('block_content_type', $entity->bundle());
+    $block_type = BlockContentType::load($entity->bundle());

+++ b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php
@@ -17,7 +18,7 @@ class BlockContent extends DeriverBase {
-    $block_contents = entity_load_multiple('block_content');
+    $block_contents = BlockContentEntity::loadMultiple();

All of these should have the block content storage injected.

jeroent’s picture

Status: Needs work » Needs review
StatusFileSize
new10.33 KB
new3.89 KB

Injected the block content storage in BlockContent and BlockContentForm class.

Status: Needs review » Needs work

The last submitted patch, 21: replace_all_instances-2377113-21.patch, failed testing.

jeroent’s picture

Status: Needs work » Needs review
StatusFileSize
new12.01 KB
new2.49 KB

.

Status: Needs review » Needs work

The last submitted patch, 23: replace_all_instances-2377113-23.patch, failed testing.

jeroent’s picture

Status: Needs work » Needs review
StatusFileSize
new656 bytes
new12 KB

This should fix the failing tests.

pcambra’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks fine and there are no other entity_load('block_content') or entity_load_multiple('block_content') left.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3f7f953 and pushed to 8.0.x. Thanks!

Beta evaluation is in the meta issue.

  • alexpott committed 3f7f953 on 8.0.x
    Issue #2377113 by JeroenT, mglaman, LinL, pcambra: Replace all instances...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.