Problem/Motivation

The walk collects every field of type entity_reference_revisions and then asks each one for its referenced entities, discarding anything that turns out not to be a paragraph.

That check comes too late. entity_reference_revisions is a general purpose field type: it can target any revisionable entity type, not only paragraphs. Inline Entity Form, for example, ships entity_reference_revisions fields on nodes that target other nodes. On a site using those, every evaluation of this condition loads the referenced entities from storage in full, only to throw them away one line later. Entity loading is by far the most expensive part of the walk, so this is work that buys nothing.

The check is also misleading to read. A method called "paragraph reference fields" that returns fields which may not reference paragraphs invites the next change to trust it.

Proposed resolution

Filter on the target_type setting when collecting the fields, so a field is only walked when it actually targets paragraphs. The instanceof check inside the loop stays as a safety net, but it is no longer what does the filtering.

Comments

trebormc created an issue. See original summary.

  • trebormc committed eb68c868 on 1.0.x
    Issue #3619002 by trebormc: Only inspect reference fields that target...
trebormc’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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