Needs review
Project:
Entity Reference Purger
Version:
1.0.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Mar 2023 at 00:31 UTC
Updated:
23 Oct 2026 at 11:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
rajiv.singh commentedSteps to produce issue before enabling the module.
1. Install devel module.
2. Translate a node (having entity/term reference field) in few available languages in the site.
- suppose node is 100.
3. Select a taxonomy term ( suppose tid is 1111)
4. Save and publish the node.
5. Do the same for its translations( Select the term, publish and save)
6. Go to pages /[Language-code]/devel/node/100 (Example - /en/devel/node/100)
7. On the devel page expand the accordion reading as VARIABLE
8. Browser search (CTRL+F) the term id 1111.
9. Now go to the term edit page /en/taxonomy/term/17341/edit and click on the delete link to delete it.
10. Repeat step 6 to 8.
11. The term id is still showing up in the variables.
Enable the module Entity Reference Purger , Check the box Remove orphaned entity references under ENTITY REFERENCE PURGER at field configuration page /en/admin/structure/types/manage/[CONTENT-TYPE]/fields/[FIELD_MACHINE_NAME]
- Repeat above steps after enabling the module , configuring field and deleting the term .
Result: The translations are still having the term reference in the database.
Solution:
Apply the patch , clear cache and verify the same with above steps.
Comment #3
rajiv.singh commentedComment #4
rajiv.singh commentedBug fixes in previous patch
Comment #5
rajiv.singh commentedCode cleaned up of previous patch
Comment #6
balagan commentedComment #7
kriboogh commentedThe patch provided doesn't take into account that a reference field can be translated and parent entity translations can have a different set of terms:
Node A (nid=100, langcode=FR, field_tid.delta[0]=200)
Node A (nid=100, langcode=EN, field_tid.delta[0]=300, field_tid.delta[1]=200)
(A node translation, can have it's field_tid set as translatable, so it can contain a different set of terms)
I saw the latest code of the module deals with this in some way already.
Comment #8
kriboogh commentedComment #9
kriboogh commentedCreated a MR. I implemented what #2 did, taking translations into account. Took the liberty of also refactoring the code into a service based setup where there is a EntityReferencePurger service that does the actual work, so module and queue processor don't duplicate code. Also provided a Hooks class.
Comment #11
kriboogh commentedComment #12
kriboogh commentedIf you need to combine this with #3260777 use this patch (it combines 3348322-MR6 and 3260777-MR7)