Allow more than one entity reference count per field/plugin.

Created on 15 November 2022, about 2 years ago
Updated 29 April 2023, over 1 year ago

Problem/Motivation

Currently, the module as well as most of the core plugins only store one entity reference per field item.
e.g. TextFieldEmbedBase

EntityUsage::registerUsage is only ever called with a $count of 0 or 1.

I believe text content like this should be tracked as 2 usages rather than 1:

<a href="/sites/default/files/my-image.png">Link to image 1</a>
<a href="/sites/default/files/my-image.png">Link to image 2</a>

Steps to reproduce

Reference the same entity twice from within the same entity track plugin.
e.g.

  /**
   * {@inheritdoc}
   */
  public function getTargetEntities(FieldItemInterface $item) {
    return ['file|1', 'file|1'];
  }

The count should be returned as 2 references rather than 1.

Proposed resolution

EntityUsageTrackBase should be updated so that it does a count of unique instances of the $target_entities then uses that as the actual usage count.

As well as all the other plugins making calls to array_unique also probably need to be removed or left as a configuration.

Remaining tasks

Provide issue fork/patch

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024