The usage count, retrieved from the entity_usage table, is taking into account the usages where the parent node does not exist anymore as well as the usages where the current entity has been unlinked from the parent node. However, on the usage page, these entries are being skipped. This is causing confusion due to the mismatch of count and the entries shown in the usage page.
Such usages are not skipped from the usage page but are marked as deleted/unlinked usages.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3065291-2.patch | 790 bytes | rishvi |
| #2 | 3065291-usage-count-mismatch-in-UI.patch | 1.41 KB | rishvi |
Comments
Comment #2
rishvi commentedComment #3
jibranThank you, for reporting the issue and creating the patch. Here are some suggestions.
Let's keep the above block, rephrase it and remove the latter one:
If the label is empty then show the placeholder.
Extra space after slashes and double space after
,also comments can't be longer then 80 chars.Again the comment is > 80 chars.
parent_id only exist for paragraph entity types so we need to check the entity type first.
if ($source_entity->getEntityTypeId() == 'paragraph') {. We also need to checksset($this->get('parent_id')->value)A space missing after = sign and spaces are missing on both sides of . as well.
This is also not true. We have
before this.
What if I change the logic in this function. There is
which we can update.
Comment #4
rishvi commentedThanks for your feedback Jibran. I included your feedback changes in the new patch.
Comment #5
rishvi commentedComment #6
jibranLet's address the failing test.
Comment #7
marcoscanoThanks for your contribution!
I'd like to better understand your use case, when you mention in the issue summary:
which count are you referring to? A value displayed in views? A value returned from an API call, such as
\Drupal\entity_usage\EntityUsage::listSources()?Getting this page right is tricky, and there are several scenarios where we might want to skip rows. Non-deleted paragraphs, for instance, are the main example, but there are others as well. The code for this controller unfortunately is becoming more and more hacky-ish over time, has demonstrated to be the root of many issues and is in fact probably the main reason that triggered the whole module refactor idea in #3060802: Refactor module architecture in a simpler, opinionated and more performant approach. Would the new approach make more or less sense for your particular use case?
Thanks!
Comment #8
rishvi commentedHi marcoscano,
Thanks for your reply.
We are displaying a list of entities and their usage count in a custom view. The count is retrieved from the entity_usage table which does not match the number of entries displayed on the entity's usage page.
The proposed resolution in the new architecture looks great. These two things on there will require us to make changes to our view but will surely improve the current experience of usage page by showing only default revision. Although, we would like to have the ability to extract usage count.
Thanks!
Comment #9
jibranI have updated IS as per #8.
@rishvi and @marcoscano I think we can roll this patch on top of #3060802: Refactor module architecture in a simpler, opinionated and more performant approach.
Comment #10
jibranBetter title.
Comment #11
acbramley commentedThis patch no longer applies to the latest beta, I tracked it down to the changes in #3056026: Remove orphan handling of paragraphs when parent exists
After reading that issue, I think we can close this one as outdated or won't fix as the paragraph orphan issue has been tidied up considerably.
Comment #12
marcoscanoI agree, the paragraphs workaround was probably the source of most mismatches people could find. Closing this for now, please feel free to re-open if you experience this again with the latest release.
Thanks everyone!