Parent Issue

#2359437: [meta] Remove entity_load* family of functions usage from the code base

Problem/Motivation

There are case where entities of the entity_view_display entity type are retrieved using the functional loader, entity_load*()

Proposed resolution

Replace calls to entity_load*('entity_view_display', ...) with EntityViewDisplay::load*()

Comments

valthebald created an issue. See original summary.

skowyra’s picture

I'm at DrupalCon NOLA and am taking at look at this

marvin_b8’s picture

Status: Active » Needs review
StatusFileSize
new5.09 KB
john cook’s picture

After applying the patch there is one more instance of using functional loading.

core/modules/image/src/Entity/ImageStyle.php:140:      foreach (entity_load_multiple('entity_view_display') as $display) {

EntityViewDisplay::loadMultiple() can be used to load multiple entities.

john cook’s picture

Status: Needs review » Needs work
snehi’s picture

Status: Needs work » Needs review
StatusFileSize
new6.52 KB
new1.43 KB

Done.

john cook’s picture

Issue summary: View changes

Updated summary.

Status: Needs review » Needs work

The last submitted patch, 6: 2723567-6.patch, failed testing.

john cook’s picture

The following is missing from the top of core/modules/image/src/Entity/ImageStyle.php

use Drupal\Core\Entity\Entity\EntityViewDisplay;

That should fix the errors from the testbot as it states where to find the EntityViewDisplay class.

snehi’s picture

Status: Needs work » Needs review
StatusFileSize
new6.82 KB
new540 bytes

I missed it.

john cook’s picture

After applying the patch from #10 there are no more calls to entity_load() for entity_view_display entity types. The patch only addresses problems with this issue.

john cook’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: 2723567-10.patch, failed testing.

ashishdalvi’s picture

Assigned: Unassigned » ashishdalvi
Issue tags: +Needs reroll

Unable to apply Patch. Patch re-roll needed.

I am working on patch re-roll.

ashishdalvi’s picture

Issue tags: -Needs reroll
StatusFileSize
new6.79 KB

Adding Rerolled Patch.

ashishdalvi’s picture

Status: Needs work » Needs review
john cook’s picture

Status: Needs review » Reviewed & tested by the community

After applying the rerolled patch in #15 there are no more calls to entity_load*().

The reroll and the original patch have the same number of files changed, insertions, and deletions, so nothing extra was added in the reroll process.

valthebald’s picture

Is there any difference between 2 patches?

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6b70606 and pushed to 8.2.x. Thanks!

  • catch committed 6b70606 on 8.2.x
    Issue #2723567 by snehi, Ashish.Dalvi, marvin_B8, John Cook: Remove...
bzrudi71’s picture

I think this causes an exception on PG during tests...
Please see PG testrunner

[18-May-2016 19:09:15 Australia/Sydney] Uncaught PHP Exception Drupal\Core\Database\DatabaseExceptionWrapper: "SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "number"

Let's see, queued for PG testing...

valthebald’s picture

What exactly can break PG? The patch contains nothing about data types

bzrudi71’s picture

@valthebald right, actually it seems that the fails are caused by #1266748: Changing cardinality lower than highest existing delta causes data loss upon save instead. The failing test is ManageFieldsTest not ManageDisplayTest, my bad ;) Will leave a note over there...

valthebald’s picture

Awesome!

ashishdalvi’s picture

Assigned: ashishdalvi » Unassigned

Status: Fixed » Closed (fixed)

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