Steps to reproduce:
There's many ways to reveal this bug. For example a view of nodes related to paragraphs, or a view of paragraphs related to the parent entity like so:
- Set up a node with a paragraph field (field_x) and a paragraph in it with some content.
- Create a view page that displays paragraphs.
- Add a relationship on "Content using field_x", set it to required.
- View the page for the view, observe that it has no entries.
The paragraph should appear on the view page since it is referenced by "Content using field_x". You can set up something similar with 2 different node types and a regular entity reference field and see that it does display the referenced entity.
There's probably many other combinations of view of X related to Y that will reveal this bug.
Remaining tasks
- Write a hook_update_N() to migrate views' relationships (and fields/filters/sorts/arguments that use those relationships) to the new format. see #124 for details
- There's some reports of broken filters due to this patch. #151
- There's some reports of old revisions showing in views due to this patch.
- There's some reports of missing paragraphs in views for a multi-value ERR Paragraphs field due to this patch.
- There's some reports of duplicate rows when having a delta field due to this patch. #134 and others
- This patch causes some UX confusion because there's now multiple ways to connect a paragraph to its parent entity in Views. #151
- ...Could be more bugs, I only read back the last year's worth of comments on this issue...
How to apply patches
If you need to know how to use a patch, please take a look at
https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...
and
https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...
please don't muddy this issue with questions about how to apply a patch.
![]()
| Comment | File | Size | Author |
|---|
Issue fork entity_reference_revisions-2799479
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hydra commentedI think I ran into the same issue - except that I had an entry from the relationship, wich was false so I could track down the problem. The problem is, that the relationship checks the vid vs the entity_id, which will break as soon as you use revisions.
Attached patch uses the right base field to do the check.
Comment #3
dawehnerAs we see here, this particular join joins to the data/base table of an entity. Given that the right key to join is the entity ID. On top of that there is the valid feature request to provide a join from the dedicated revision field tables to the revision data table, but that's a different battle to fight.
Ideally we would have tests here which actually work properly.
Comment #4
miro_dietikerYes and no:
I rarely commit bugfixes without tests. You need a very solid excuse for that. So are we living in an almost ideal world? ;-)
Comment #5
dawehnerFair point :)
Comment #6
dawehnerTo continue though, I doubt we can know in which world we are living in .
Comment #7
hydra commentedLooks like this needs to be $field_name . '_target_id', too then :/ The view stops working when the revision id no longer ist the same as the id itself.
Comment #8
stmh commentedHi,
attached is a new patch combining #2 and #7 into one. This fixed a similar problem on our end.
Comment #9
d34dman commentedThe patch in #8 makes it behave like normal "entity_reference" field. Means revision specific referencing will not be available if we apply that. Thus defeating the purpose of using "Entity Reference Revisions" field in the first place.
Having said that, it is common requirement that we might need the latest revision only, where a behaviour like normal "entity_reference" is expected. So I suppose we expose two reverse reference field,
1. A reverse reference that behave like normal refrence field
2. A reverse reference that acts on revisions
At the moment, it looks like the reverse reference field doesn't behave like either. That is, we can't load a reference content at all.
Thoughts?
Comment #10
abaier commented#8 solved it for me temporarily. Hopefully this could be fixed. I was scratching my head why some paragraphs did not show up. So, it was because I deleted them from a node and added some new ones. Without a required relationship to the host all the revisions were shown, even those which were deleted.
Seems to be kind of similar to this issue:
https://www.drupal.org/node/2741937
Comment #11
jpoesen commentedConfirming that the patch in #8 did the job for me.
My scenario: a view (block display) of paragraphs showing titles for a given node, to render alongside a node.
Created a required relationship to the paragraph reference field and a contextual filter to Paragraph: Parent ID
Before the patch, all paragraph titles were shown, even the ones of paragraphs that had been removed from the node.
After the patch only the paragraph titles of the remaining paragraphs are shown -- for me this was the expected behaviour all along.
Comment #12
abaier commentedThis problem does still exist in 8.x-1.2. Any news on this?
Thanks in advance!
Comment #13
tacituseu commented@D34dMan: attached pretty much what you described.
My use case is a view with some of the fields from referenced parent showing values at the time the reference was created, and some from latest revision.
Sorry for no tests :), attaching here instead of new issue with feature request because #8 isn't a proper solution, and it looks like there is an interest for it here.
I can't spend too much time on it right now, so feel free to improve.
Comment #14
tacituseu commentedReverse relationship needs some work.
Comment #15
d34dman commented@tacituseu, thanks for pushing this, will do testing during weekends. busy schedule :(
Comment #16
tacituseu commentedComment #17
tacituseu commentedLooks like it all boils down to hardcoded
'entity_id'inDrupal\views\Plugin\views\relationship\EntityReverse::query(), unfortunately couldn't find a way around it, so core patch attached (patch is green on 8.4.x, see results here https://www.drupal.org/pift-ci-job/610454).Leaving at needs work as it needs a look from someone more familiar with views, not sure if I'm not abusing 'revision' definition key, couldn't find any docs about it.
Comment #18
berdirWe could always subclass that and use our own plugin for our field? And if we are going to fix it in core, then it will require an actual issue.
I'll try to have a closer look at this soon.
Comment #19
tacituseu commented@Berdir: yes, subclassing looks perfectly doable.
Comment #20
tacituseu commentedHere it is, went with the 'entity_reference_revisions' as id and
EntityReferenceRevisionsas class to stay consistent with other ERR views plugins.Extended from
Drupal\views\Plugin\views\relationship\RelationshipPluginBasebecauseDrupal\views\Plugin\views\relationship\EntityReverseis pretty much only overriding the same method.Comment #21
tacituseu commentedMight as well leave 'revision' alone.
Edit:
Note to potential testers: it changes id's of the relationship fields so it will "Broken/missing handler" existing relationships and fields relying on them.
Comment #22
d34dman commentedI have tested it by apply patch and creating a new view. I am able to add two new relationship types now. Namely "Entity_XXX referenced from Entity_YYY" and "Entity_XXX revisions referenced from Entity_YYY". I have checked by trying to display revision id and it works. Good job.
Comment #23
drikc commentedThank you, could successfully do a relationship to content entity from a paragraph view.
Comment #24
johnpitcairn commentedThe patch at #21:
Thanks!
The category labelling when I get to field selection on the content node is possibly a little obscure. It's not clear what the difference is between "Content (historical data)" and "Content revision".
Comment #25
johnpitcairn commentedUm ... hang on ... does this break relationships to relationships? I have a (now broken) view that uses a custom menu link > content >paragraph > paragraph > field relationship chain. That gets broken handlers with this patch (expected), but there doesn't now seem to be any way when adding a new ERR relationship to specify the relationship that it depends on. So you can't chain downward relationships?
Comment #26
tacituseu commented@John Pitcairn: I'm not using it with paragraphs, but I do use it for chained relationships, both forward and reverse, there is a problem with current patch, this part:
the second foreach might be redundant and just results in relationships with identical name but based on different tables
as
core\modules\views\views.views.inc::views_field_default_views_data()already does:So it could be that you picked the wrong combination, or there is something about paragraphs that isn't taken into account, will look more into it and the interaction with custom
ContentEntityin a week or two.Found the group/category confusing too, "Content (historical data)" comes from core, so not likely to change, and changing ERR to start using it instead of "Content revision" might be even more confusing, 'group' label definition should vary too if it is a revision and doesn't in current patch.
Comment #27
johnpitcairn commentedYes, I had to re-create the relationship/field chain and missed one of the initial relationships. The handler is working as expected.
Comment #28
johnpitcairn commentedI'm not familiar enough with the code but I do note that there are 2 very similar relationships available: I think one is a relationship to (or from) the entity without revision, while the other is a relationship to (or from) the specifically referenced revision?
If so, they are both useful. For example for my admins I might have a "media usage" view that displays media used only in current revisions of content, with another embedded view with aggregation that counts usage in any revision of each content item. Both relationships would be required to do that.
Comment #29
imclean commentedThanks. The patch in #21 applies cleanly to dev and allows displaying fields from the referenced paragraph's host entity. I haven't tried anything more complex yet.
Comment #30
johnpitcairn commentedPatch no longer applies to latest dev.
Comment #31
tacituseu commentedComment #32
tacituseu commentedTriggering tests to check.
Comment #33
tacituseu commentedBack to needs work for tests.
Comment #34
vasikeIt seems something still missing: relationship for Base fields
Ex: Drupal commerce uses this field as basefields for Billing profile
issue: #2819603: Can't add a views relationship to the billing profile
And here is an updated patch that includes the base fields (single and multiple valued)
Diff included.
Still needs tests - (Needs review temporary)
Comment #35
johnpitcairn commentedHmm ... I'm patching via composer and cweagans/composer-patches and that was failing. I'll take another look. Thanks @tacituseu.
Comment #36
tacituseu commented@vasike: Thanks for base fields integration, will take a closer look soon.
Also, for those having
Error "Column 'langcode' in field list is ambiguous" thrown in TranslationLanguageRendererwith this patch, see #2896381-30: "TranslationLanguageRenderer" uses the wrong table for the "langcode" column with entity revision views.Comment #37
tacituseu commentedComment #38
stevieb commentedthe patch in #34 worked for me ...
Comment #39
s427 commentedPatch #34 works for me too, as far as I can tell.
Comment #40
coufu commentedPatch #34 wins
Comment #41
miro_dietikerSorry, this is simply too much code for a blind commit. Supporting comments won't help here: We need tests.
Comment #42
cbrasfield commentedTrying out #34 with views REST and I'm not sure the field names are friendly (field_image-revision_id, field_image-revision_id_1). Don't know if there's anything that can be done with that.
Comment #43
tacituseu commented@cbrasfield check #2831233: Field tokens for "historical data" fields (revisions) contain a hyphen, breaking twig templates and throwing an assertion error
Comment #44
maxplus commented#34 solved this issue for me https://www.drupal.org/node/2819603
Thanks!
Comment #45
jantoine commentedI've run into an issue where a reference to a parent node from a paragraph is successful but a reference to a grandparent node from the parent node still has the same issue as the original.
Comment #46
tisteegz commented#34 worked for me also.
Comment #47
lamp5#34 works perfect! Thanks
Comment #48
csedax90 commented#34 is working fine
Comment #49
tacituseu commentedComment #50
tacituseu commentedComment #51
nicobot commented#34 Works great for me! Thanks!
Comment #52
idebr commented- Added a test that checks a View result set for a node title based on a relationship from the entity_test_composite entity. This should fix #41
- Fixed Code sniffer warnings in the patch
Comment #54
miro_dietikerAs we had issues with revision duplication and joining on the proper field, we should write multiple revisions on the Paragraph and the host entity and check that there are no duplicate result rows.
Comment #55
idebr commented#54 Added revisions to the composite and host entity. Added assertion for a single result with the updated data.
Comment #57
miro_dietikerQuickly reviewing the code a bit, not tested yet.
I count below 8 $key inline conditions and twice a 6 row if base on $key. It makes me feel like we should maybe simply cover these two cases one after the other?
Hm... Same above... Not sure what's better. What do you think?
Needs special test coverage for cardinality 1.
Are we really supporting an ERR to a target entity type that is not revisionable? What's the purpose of an ERR then?
And yeah, didn't recently think about the case where the host entity type may not be revisionable.
That would need a test case as well..
I would guess that without putting these relations as required, if you delete the host entity, you still have ghost results without host?
Comment #58
miro_dietikerIdentified a Views use case: Sometimes i like to see a count of Paragraphs per node in a view. And when i work with unpublished Paragraphs to hide incomplete items, i would like to see a dedicated unpublished Paragraphs counter. Both numbers though need recursion in the current situation or would only count the top level items.
Should we create a parent meta issue to identify and discuss views use cases?
Comment #59
scott.whittaker commentedIt's almost like Entity Reference should be linking content Relationship entities rather than directly referencing entities. That way you could have different Relationship types where you could configure the desired behaviour for cascaded deletes and so on.
Comment #60
miro_dietiker@scott.whittaker There are multiple issues about garbage collection and it's a hard problem. It's on our #2954487: New Roadmap as one of our top priorities.
Comment #61
berdir> And yeah, didn't recently think about the case where the host entity type may not be revisionable. That would need a test case as well..
We don't allow to create that in the UI: \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::storageSettingsForm()
Probably not strictly validated somewhere, so you could theoretically work around it, but not sure it's even worth to add more checks and obviously also can't be tested then.
Comment #62
charginghawk commentedHaving trouble applying the #55 patch through composer. May be a versioning issue (I'm using Paragraphs which uses entity_reference_revisions 1.3). #34 applies, so using that for now.
Comment #63
hgupta28 commentedTested #55, working as expected.
Comment #64
miro_dietikerAt least we want to have separate test coverage for cardinality 1.
Comment #65
diamondseaUpdated #55 to patch format (removed headers) so it can be used with Composer.
Comment #66
el1_1el commentedAs mentioned in comment #21, patches break all existing err/paragraph relationships so hopefully a dbup is included if committed
Comment #67
pfrenssenI think the patch is hard to read because of the heavy use of ternary operators in it. Example:
If this was rewritten to handle the base relation first, and the revisions second, then there would be a little bit of code duplication, but much easier to read. It would also be more consistent with the rest of the
views.views.incfile which prefers duplication over ternaries.Comment #68
jax commentedI agree with Pieter, that is not readable. It is the fewest possible amount of lines though.
Just writing it twice would make it more readable and adds an if and else. For such things I prefer this approach:
Comment #69
miro_dietikerI really do not care about "fewest possible amount of lines". Readability and simplicity of code first.
So let's convert this please to a straight forward non-ternary-overloaded version.
Comment #70
tacituseu commentedPersonally I'm waiting for the following core issues before committing more time: #2706431: provide Views reverse relationships automatically for entity base fields, #2795455: Views does not add relationship data for entity_reference fields not defined in configuration and are multiple, #2895578: Views does not add reverse relationship data for entity_reference fields not defined in configuration.
Comment #71
sjancich commented#65 doesn't apply for me via Composer (I'm using D8.16, and the 1.6 release of ERR).
Comment #72
dieuwePatch #65 applies with composer when using the latest dev version (but not 1.3 or 1.4, only #34 applies against those).
I don't have time to investigate, but I am seeing the following notice on a view with a paragraphs relation after applying this patch:
Notice: Undefined index: base in Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo() (line 292 of core/modules/views/src/Plugin/views/query/QueryPluginBase.php).And also getting a MySQL syntax error when using an exposed text search filter that uses the relation. Can anyone else verify?
Comment #73
johnpitcairn commented#34 will also apply against current dev using composer.
Comment #74
littlepixiez commentedJust a note that #34 worked for me against 8.x-1.6 using composer and fixed issue for me (whether that be temporarily or not!). Had to reapply relationship. :) Thanks.
Comment #75
opi#34 works for my on entity_reference_revisions 8.x-1.6, thanks !
Comment #76
ñull commentedI agree that this still needs work. I applied patch 2799479-34-views-rel-fix.patch and it does not fix the related (duplicate) issue #2941499-7: Duplicate nodes when using Views relationships. I still see duplicates when I add a paragraph relationship.
Comment #77
miro_dietiker@ñull Are you multilingual?
Comment #78
ñull commented@miro_dietiker I guess it is not relevant here that I am multilingual, but the site is not.
Comment #79
handkerchiefSame result for me as #74
Comment #80
ñull commentedI now installed dev version and patch #65. Still does not fix the supposedly duplicate issue #2941499-7: Duplicate nodes when using Views relationships. I keep seeing duplicates when I add a paragraph relationship.
Comment #81
kienan commentedI tried the patch from #65, and it didn't seem to do what I expected. I still encountered duplicates from views (even after replacing the relationship)
Furthermore, any views with relationships configured caused whitescreens, with errors similar to:
"No entity type for field field_custom_field_name on view view_machine_name"
These errors continued until the views were manually fixed by replacing the relationships.
Comment #82
aleksipSo, my understanding is that this issue means that Views integration of Paragraphs is effectively completely broken? I have tried the latest patch and it does not fix all problems (some of which have been described in other issues marked as duplicates).
This issue is currently over two years old and has 92 followers. Any chance the priority could be bumped to Critical, or at least Major?
Comment #83
miro_dietikerI have put this issue on the bigger Paragraphs Roadmap for more visibility a while ago.
Let's promote it to Major for now. We can only promote it to Critical if someone takes ownership over this issue and will push it forward because it is critical to him.
There are clear statements above how to improve this issue and hopefully make it ready.
We can also cover missing use cases in tests in follow-ups. But keep in mind that we will then need to update views in case we change definitions that would lead to broken handlers in existing views.
Comment #84
demonde commentedIs there any workaround?
E.g. I could print out the "Paragraph: Parent ID" as views field and use the Views field formatter project to render it. That is not a nice way but should work.
Does anybody know a better way until the issue is solved?
Comment #85
markdc@demonde
Could you please explain in detail your method? I'm pretty desperate at this point; I'll take the not nice way.
Comment #86
demonde commented@fatmarker: Ok but I have not tested this yet.
You could use
https://www.drupal.org/project/views_field_formatter
( or as alternative https://www.drupal.org/project/views_field_view )
an send with one of these modules the value of the views field "Paragraph: Parent ID" to another view.
It is obvious that this way is all but performant because for each row you have to render one view and it might be tricky to get good markup.
Comment #87
piggito commentedAbout this comment in #72
The
line is preventing the patches at #55 and #65from applying to release versions.
Drupal script adds an extra section to info file like
then we have a line break instead of
which invalidates the patch.
Comment #88
rajveergangwar#8 Worked for me... Thanks
Comment #89
igonzalez commented#8 Worked for me... Thanks
Comment #90
eiriksmReroll (the only change is getLowercaseLabel => getSingularLabel (which was the last commit on the branch, and the base for release).
Comment #91
eiriksmJust uploading a patch that can be applied with composer on the stable branch. Probably fails testing, since I removed some changes to an .info.yml file that would not apply
Comment #92
arsn commentedHello,
2799479-91-DO_NOT_COMMIT.patch from #91 works for me. Many thanks!
I've finally managed to fix "Paragraphs in Views shows all revisions" thanks to explanations in #2999730#comment-12775116.
I had to update drupal to 8.7.8, paragraphs to 1.9 & entity_reference_revisions to 1.7 (their latest stable release to date), apply the patch from #2799479#comment-12620465, reconfigure the whole view, and get rid of a nasty hook_views_query_alter() which was quietly corrupting my results.
Best regards
Comment #93
ikit-claw commentedWhy have you called it do not commit? It is going to get many questions when the deployment is reviewed....
Comment #94
smazThat patch is just one that will apply to the stable branch without errors, so people can use it now & apply it via composer without having to use the dev branch of the module. 2799479-90.patch is the one that should be being committed - the only change between the 2 is that the DO-NO-COMMIT one doesn't attempt to patch tests/modules/entity_composite_relationship_test/entity_composite_relationship_test.info.yml as when applied to stable it results in:
Comment #95
ikit-claw commentedThanks @smaz but 2799479-90.patch will not apply DO-NO-COMMIT does.
Comment #96
smaz2799479-90.patch applies cleanly to the dev branch, where it will get committed:
I'll try and get a proper review in later to help get this RTBC!
Comment #97
ikit-claw commentedThanks
Comment #98
yechaozheng commentedPlease ignore this comment
Comment #99
yechaozheng commentedCannot apply the patch 2799479-90.patch from #90 with below error. So I just correct the patch for this file patching failed (tests/modules/entity_composite_relationship_test/entity_composite_relationship_test.info.yml).
Comment #100
duneblI confirm #99 solve my issue
=>don't forget to check "
Require this relationship" checkbox.Comment #101
arsn commentedI confirm too #99 fixes the issue. Thanks
Comment #102
j-lee#99 works for me too. Thank you.
Maybe RTBC?
Comment #103
j-leeHmm. There is an issue if you add the field delta for sorting. Then the results shows multiple times.
SQL query before setting the field delta sorting:
Result:
After adding the field delta for sorting:
Result:
Comment #104
j-leeI've been investigating a little more....
The patch works as expected. The problem was a wrongly configured view where I had to configure the relationships before the context filters.
The delta sorting criteria are not required because the view shows the paragraphs within the right order.
Comment #105
katyrose commentedIs there a version of this patch that will work for the 8.x-1.7 branch? Tried applying the one in . https://www.drupal.org/project/entity_reference_revisions/issues/2799479... and wound up with some nasty PHP errors
Comment #106
eiriksmThe patch in 91 (https://www.drupal.org/files/issues/2019-10-07/2799479-91-DO_NOT_COMMIT....) should apply to 1.7
Comment #107
trondsenjd commentedConfirming #91 works for me on 1.7. Thank you @eiriksm!
Comment #108
dww#90 no longer applies to 8.x-1.x branch due to conflicts from #3100140: Mark as compatible with Drupal 9, so I rerolled it. Since #90 no longer applies, interdiff isn't possible, so here's a raw diff of the 2 patch files.
Comment #109
dwwp.s. Thanks to the patch conflict, I noticed this bug in #90:
This is wrong. entity_reference_revisions isn't (yet) part of core. ;) This needs to be
entity_reference_revisions:entity_reference_revisionsinstead. ;) Already fixed in #108. Just calling it out here so folks know it was an intentional part of the diff between #90 and #108.Cheers,
-Derek
Comment #110
arcaicJust adding this in case its of use to anyone...
We are experiencing this issue with views with paragraph relationships returning wrong/inconsistent results and while the patches do fix the issue, as has been noted, they break existing views which need to be rebuilt.
As we have 50+ views with multiple displays its a major effort for us to rebuild them so I came up with the following bodge as a workaround until an update mechanism for the patches is available.
For any view with a relationship of 'paragraphs_item_field_data_node__field_paragraphs' I unset it and replace it with a version that works (for me). It probably is not a universal fix for all use cases and has had limited testing by us so far (not in production yet) but is much less disruptive as a work around.
You may/will need to adjust this for your use case and please test thoroughly. Do not use in your production site.
Add the following in a custom module in the module file....
If anyone can see major issues in this approach as a temporary fix then please let me know.
Andy
Comment #111
pianomansam commentedI'm using #91 to patch my 1.7 install. The report of duplicated rows when sorting by delta, which J-Lee reported, is a bug I'm observing. J-Lee reported they got around it because they didn't need it, but I do.
In an attempt to remove the duplicates, I added the "Content revision: Is Latest Revision" filter, as I will only need the latest paragraphs and their revisions. This, in turn, causes an error that "Base table or view not found".
The field I'm attempting to connect via a reference in "field_steps".
Comment #112
wombatbuddy commentedI tried to apply #108 on Drupal 8.8.0 and got:
error: patch failed: tests/modules/entity_composite_relationship_test/entity_composite_relationship_test.info.yml:7
error: tests/modules/entity_composite_relationship_test/entity_composite_relationship_test.info.yml: patch does not apply
If remove the code related with "tests/modules" the patch does the job.
Comment #113
marcaddeo commentedRerolled #108 without tests
Comment #114
liquidcms commentedfixed my issue of views reverse relationship not working.
Comment #115
dww@marcaddeo re: #113: Why would you do that? ;) We want tests for this to be committed...
Comment #116
alison#108 applied cleanly for me *after* I updated ERR from 8.x-1.7 to 8.x-1.x-dev. (I've got core 8.8.1.)
(If (if 😁) my experience accurately represents the situation, folks can just consider #113 a "band-aid" for people who are using 1.7 but still want the fixes provided by this patch, ya? ...And if not, never mind!)
Comment #117
alisonOops sorry, forgot to say -- #108 worked great for me, fixed the problem!
---------
Re: applying the patch: I didn't have the dev version before, so/but, for composer folks, in case it helps anyone...
composer require drupal/entity_reference_revisions:1.x-dev, then added the patch to composer.patches.json, then rancomposer update drupal/entity_reference_revisionsto apply the patch -- weirdly, when I did the last step (composer update on ERR), it simply removed the module, it didn't reinstall with the patch. (If I simply run composer update on ERR one more time, everything ends up correct, but it was weird, y'know?)Add patch to composer.patches.json
Run
composer require drupal/entity_reference_revisions:1.x-devComment #118
johnpitcairn commented#108 working here, tests passing, agree it's RTBC.
The composer-patches failure to apply then deleting the module is a fairly well known bug, you can just run composer update again so it will reinstall and patch.
Comment #119
stopopol commentedI just applied #108 on the latest dev and running Drupal 8.8.3.
It did break the pre-set filters and relationships in my view, but after I re-created the filters and relationships, everything worked.
Comment #120
superlolo95 commented#108 worked for me
Comment #123
arthur_lorenz commented#108 also worked for me, thx!
Comment #124
arthur_lorenz commentedAfter further testing I have to revoke my statement a bit: Patch works fine for newly created realtionship in views. Already existing views might break due to change of field name change in relationship (e.g. instead of
field: field_paragraphsit's nowfield: field_paragraphs_target_id. So we need an update script here, that updates field names i guess.Comment #125
el1_1el commented+1 to #124, which has also been mentioned in #21 and #66
Comment #126
johnpitcairn commentedAgreed on #124, the patch at #113 that was passing tests had the tests removed. #108 is not passing.
Comment #127
gthibert commentedWith patch #108, when using Rewrite Results, I just have access to {{field_name-revision_id}} and {{field_name-revision_id__target_id}} as Replacement Patterns, not to the field value (a string in my case).
Comment #128
studio-days commented#108 worked for me in Drupal 8.8.5. Because it was my first time using Composer to patch a module I thought I'd write out the steps I've just learnt. Maybe it'll help someone:
Install to declare patches:
composer require cweagans/composer-patchesChange to the dev version of the module:
composer require 'drupal/entity_reference_revisions:1.x-dev'Add patch under "extra" in composer.json:
Apply the patch:
composer update drupal/entity_reference_revisionsLook out for this message:
Flush the damn cache:
drush crComment #129
oldspot commentedI can confirm as well that patch #108 works with core '8.8.5' and entity_reference_revisions '1.x-dev'.
Comment #130
dercheffeHmm okay how "save" is it to use the patch in #108 ? Is it only affecting the displaying of views or is it changing data in the database permanently? Imo a real major issue.
Comment #131
alison@dercheffe My understanding is that the patches on this thread provide a redo/rework of the views relationship, effectively adding a new views relationship -- there are no effects on ERR data.
Great point in #124 about existing relationships -- btw, I was skimming through the entire thread, and this side-effect was mentioned by @tacituseu three years ago back in #21. Any chance "it doesn't matter" because the relationships are broken now, so theoretically no one's using them anyway...? Just kidding...mostly! :D (I'm afraid I don't know how to write an appropriate update hook, so my purpose here is to offer an explanation of what the patch does, share a fun historical fact, and make a hilarious joke.)
Comment #132
bubuThanks for #108, it worked for me. I came here after Upgrading D7 to Drupal 8.8.5 with migrating from Field collection to Paragraphs (8.x-1.11) and Entity Reference Revisions (8.x-1.8). Migrating was successfully with a Paragraphs patch, contents displayed well, but with views I experienced this issue. I followed instructions in #128. Updating to dev and #108 helps me. After installing I have broken old relationship, but it was easy to recreate them. Thanks!
Comment #133
rob230 commented#108 working great for me for Drupal Commerce orders or payments being related to billing profiles.
Comment #134
nsciaccaI can confirm that the patch fixes the relationship but does not work with the core delta field. The issue is that adding the "delta" field, whether for display or sorting, is defined in views.view.inc and is designed to work for multiple fields - which it does by adding the table again and joining on the entity_id instead of the target_id to display the field. It could just pull the delta from the already joined table but it doesn't seem to know about that. So instead it joins the table again with a new alias on the wrong parameters and therefore creates duplicate rows so every child reference is listed with every existing delta.
I'm wondering if the fix is to have entity_reference_revisions define its own delta field so it can use the same base table already added. I'm looking into this but asking for anyone's help who maybe has more experience with views data hooks/alters.
Update: I fixed my delta sorting by using the following code in a custom module:
My example above is sorting on 2 different levels of paragraphs, so likely you may only need 1. I got the paragraph table aliases from the Views query display. It's not perfect but does the trick for now. Hope this helps someone else.
Comment #135
replicaobscura#108 applies for me on the latest version using git apply, but it for some reason fails whenever I try to apply it via composer.json. I even tried re-rolling it, but the resulting patch file still doesn't apply with composer. Is anyone else experiencing this?
Update: The no-tests version from #113 actually applies correctly, so it seems to just be the tests that cweagans/composer-patches can't seem to apply. While #113 is certainly not an ideal solution, I'm glad it exists for now.
Comment #136
jenniferhoude commented#108 patch not working for me.
Used #128 to install patch with composer.
View is still broken when trying to use filter 'Is latest revision'.
Using with Drupal 8.9
Comment #137
eigentor commentedThe patch does not apply anymore to version 8.1.8 of entity_reference_revisions
Strangely it is only the small bit where the two dependencies
are added to entity_composite_relationship_test.info.yml
Weird how that can be a problem.
Needs a quick reroll, should be easy to do.
For all people trying to apply the patch:
e.g. when using the trusty old
patch -p1 < [patchfile]command to manually apply patches:
remove the .orig and .rej files created in tests/modules/entity_composite_relationship_test, manually add the two lines shown above to the named .info.yml file and you are good to go.
The functionality still works.
For those that are looking for the right relationship in Views relationships after applying the patch: they all sound so similar!
It is named:
"Content revision using [name-of-paragraphs-reference-field].
Category: Paragraph
Description text reads as follows:
"Relate each content revision with a [name-of-paragraphs-reference-field] set to the paragraph.
Comment #138
aanjaneyam commentedI have been following this issue for a long time but now I feel if it would be ever solved.
Also, I am a bit confused here with so many responses and this bug has literally stopped one of the site development where landing pages are to be built upon on views based on paragraphs in content types thus requiring a relationship to the content. Is there a workaround other than the patch or do we just have to use the patch above? I was wondering if there is any other module which can help address this issue.
I shall be highly grateful for any help or clues explained in plain words as I am still trying to grapple with the Drupal 8 composer based workflow.
Comment #139
rob230 commentedHi aanjaneyam,
It depends on how you have your composer.json set up.
If you are using the standard Drupal composer then you should already have cweagans/composer-patches set up and you just need to add the patch to the extras section like this:
Comment #140
aanjaneyam commentedI am using varbase distribution. There is a composer.joson in project root but it does not list ERR module. It appears they are using any sub composer.json hidden somewhere in the codebase (maybe install profile). I will have to dig a bit more to find the location of the composer.json used. Or, I am not sure, if I can just blindly follow #128 above and include the patches statement in the main JSON file at the project root. I am running entity_reference_revision version 1.8 (released 11 March 2020), so do I really need to update to dev version first before applying the patch.
Below is the main composer.json in project root
Comment #141
aanjaneyam commentedCannot apply the patch on version 1.8 (the release date for the same as the dev version). I am not sure if version is the reason
Comment #142
aanjaneyam commentedDo we need to upgrade the module form 1.8 to 1.x-dev in order to be able to successfully apply the patch.
Comment #143
johnpitcairn commented@aanjaneyam: Yes, 8.x-1.x-dev is required to apply the patch.
Comment #144
tibezh commentedThe patches from #108 and #113 work. But it breaks already existing relationships.
Comment #145
gustavowal commentedIn our case the patch from #108 seems to resolve the broken relationships that showed after Core + Commerce Updates.
Comment #146
super_romeo commentedEntityType::getSingularLabel() now handles lower-casing the entity type label; getLowercaseLabel() deprecated.
https://www.drupal.org/node/3075567
Comment #147
tbsiqueiraI tested patch #108 and #146, both are not working for me, I still can see old paragraphs in my view.
Comment #148
realgt commented#146 worked for me
Comment #149
stopopol commented#146 can be applied on the latest dev, but breaks all pre-existing relationships.
Also it only seems to partially fix the problem as in my case now more nodes are recognised to have a particular paragraph as a filter criteria but not all of them.
Comment #150
dunebl#146 can be applied on the latest dev, but the relationship to the host entity (a node in my case) does not work with multiple values...
I have used this relationship:
Relate each Content with a
field_my_paragset to the Paragraph.Edit to add: I have clicked on the "
Require this relationship" checkbox of the RELATIONSHIPS settingsAfter adding the (required) relationship, I can add the 'title' field of the node (using this relation)
but the column is emptyEdit to add: This is not working at 100% because I can only see one paragraph for a given node/field but this field is a multi-value field and contains 2 items (paragraphs)
Before clicking on the "Require this relationship" checkbox of the RELATIONSHIPS settings I could see my 2 items/paragraphs for this node/field.
Clicking on this checkbox make disapears one of my 2 paragraph items
Here is the query generated by that views that should display all paragraphs (only one type=
my_parag_type) added to a node through the fieldfield_my_parag. It display only one paragraph but the field contains 2 paragraphsComment #151
dalinFor me the patch in #146 is working well enough.
Until there's an update hook to fix existing views, here's a quick way to find all the views that need to be manually fixed: Search your config folder for
paragraphs_item_field_data. FWIW, I think the technique described in #110 isn't great because the views will still be broken when you edit them in the UI.This patch does add some UX issues though. There are now two options for adding a relationship from a host entity to a paragraph. I'm not sure what the practical difference is. AFAICT they work the same.

However, this patch does seem to break some filters: I have a view of nodes, with a relationship to a paragraph, and an exposed filter of a field on that paragraph. Before this patch the exposed filter worked fine (other than the bug that this patch is fixing). Now I get an error in the Views UI:
This is despite that the filter is using the relationship, and no amount of clicking on things in the UI can fix it.
Comment #152
dalinComment #153
dalinComment #154
fernly commentedConfirming that patch #146 works with the current dev version.
Creating a view from scratch is recommended if not required for this to work.
Comment #155
adinac commentedThis is the patch from #108 (the one with no tests, because the patch from #146 didn't apply) with the fix for: EntityType::getSingularLabel() now handles lower-casing the entity type label; getLowercaseLabel() deprecated (https://www.drupal.org/node/3075567).
Comment #156
superlolo95 commented+1 for #155
with entity_reference_revisions version: '8.x-1.9'
Comment #157
yfma commented#155 can apply on 8.x-1.9. But the relationship is not working properly. Once add relationship and set it as required, some items disappeared from the view. Our situation is having multiple paragraph items on paragraph field.
Comment #158
nikita_ttThe attached patch is mostly a copy of the #155 but some lines of the removed code were returned. They are needed for keeping already existing relationships not broken. I didn't test it properly but for the first view it works and might be useful for someone as a fast workaround solution.
Comment #159
bjcooper commented#158 works for me for adding the content revision relationship, but if I attempt to filter the content revisions by "Is Latest Revision" I get the following error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mysite.field_myfield_paragraphs_item_revision_field_data' doesn't existThe table it's trying to find there looks pretty bizarre (I confirmed that the "Content revision" is selected as the relationship to use for the "Is Latest Revision" filter).
Comment #160
socialnicheguru commentedin my install, the contextual filter is applied at the start.
Once I use the "Filter criteria", the contextual filter cannot be reset. This might be new behavior of views in D8.9+. However http://drupal.org/project/filter_harmonizer states something different
The contextual filter, parent: Paragraph ID, can only have "Display all results for the specified field". None of the other options work. In addition no other validation worked. I tested with no filter criteria to see if the contextual filters would work.
The "Contextual filters" and "Filter criteria" do not have overlapping filter values. For example the contextual filter has "Parent: Paragraph id" and the "Filter criteria" has taxonomy terms.
Comment #161
hudriWe are using #158 successfully on multiple projects using a standard "Content using field..." relationship. The basic functionality is given, and works as expected with any cardinality (but we also did not use it with obscure setups with revisions or contextual filters).
Comment #162
drews_manI add the functionality which checks the entity id, not revision. It helps me when I work with paragraphs.
Comment #163
drews_manMinor fix for the previous patch.
Comment #164
jaykandariTested
I created a view of paragraphs and added a relationship with content having fields which references the current paragraph type.
#158 doesn't works for me.. !
But, #163 works for me.. !
Comment #165
stopopol commented#163 also worked for me after I had cleared the cache!
Comment #166
kazah commented#163 works great
Comment #167
kleinmp commented#163 fixed this issue for me too on a simple paragraph view with a relationship to it's parent node.
Comment #168
Anonymous (not verified) commentedHi, all
I have a content type that contains an entity reference field for Paragraph type. Within the paragraph type, I have a field which is an entiity reference to a taxonomy.
Node -> Paragraph -> Taxonomy term reference
I need a views' block with similar content to be shown on the page of current node. That is the block should display similar nodes in which at least one taxonomy term coincides with such a term in the current node.
The problem is that the standard context filter of "Has taxonomy term ID" does not work.
Will the patch (for example, #163 ) in this topic help solve this problem? Drupal 9.3
Thank you in advance for your response,
best regards,
Savage
Comment #169
philyPatch #163 saved my day using Drupal 8.9.20, Paragraphs 8.x-1.2 and Entity Reference 8.x-1.9
Here is my use case:
The next step is to add to the core /admin/people views the company the user is related to by adding 2 relationships: user to paragraph and paragraph to node (and this is where relationship on "Content using field_x" fails).
That second relationship now works with patch #163 applied.
Thanks
Comment #170
aanjaneyam commentedCan we apply both patches #158 and
#163 together as they serve different purpose and functionality. Also do we need version 1.9 or 1.x-dev as they both appear to be released on the same day.
Comment #173
Katy Jockelson commentedI'm curious if a fix has been rolled into any version of the nodule for D9?
Unless I am mistaken, this bug means that there is effectively no paragraphs/views integration right now. At least not that involves fields from both a paragraph and its 'host' node. I wish I was more of a developer, and able to help wit the solution. In the absence of that, I'll risk being annoying and asking - isn't this kind of a big deal and something that should be applied to the next dev version at least?
Comment #174
dieterholvoet commentedI also encountered this issue today, but without this patch. Removing it from the issue description since it is unrelated.
I created a core issue: #3276456: Latest revision views filter causes 'Base table or view not found'
Comment #175
edysmpHey folks! Thanks for working on this one.
I'm using #172 in a D 9.3 project with success.
Comment #176
cgoffin commentedHere also the patch generated from the merge request.
Comment #177
webdrips commented#176 worked for me on D 9.4.0 and ERR 1.9
Comment #178
kazah commentedThank you!
#176 worked for me on D 9.4.0 and ERR 1.9
My problem is that only admin could see paragraphs field.
How can I solve it?
Comment #179
dalin@kazah
That sounds unrelated. It sounds like either you have a permissions problem, and/or a caching problem. Can you search through other tickets, and if you don't find anything open a _new_ ticket so that this one doesn't get muddied?
Comment #180
kazah commentedYes, I think it's related to paragraph module.
Permission problem with unpublished paragraphs.
Comment #181
lazzyvn commented#176 It works great. There is a phpsc code standard issue, it should be merged with the development version and we will fix all latter
Comment #182
duneblHere is the output of #176 applied to last version (1.10)
Comment #183
maenjuel#176 worked for me on version 1.10, though applying the patch returned the same output that DuneBL mentioned. However, the relationship now works as expected.
Comment #184
jeff.a commented6 years and running to get one of most popular Drupal modules to work properly with views?
Sorry to sound like a hater, this issue killed my day and I'm shit posting. #176 doesn't work under certain circumstances, like with workflows when the content isn't published. I wish I could contribute, but as a lowly front-end guy there's probably not much I can do. I will contribute monetarily though if there's a transparent way for me to do that.
Comment #185
vistree commentedFor me applying patch from #176 duplicates the paragraphs in some cases. It seems that using content translation + adding a node translation causes this problem. I already added a paragraph language specific filter to my views display.
Update: I were able to fix this problem by adding an additional language filter for the parent node (content) entity within the views display.
Comment #186
ifrikI'm a bit confused with the state of the different patches in here, but #158 works on 9.5.3.
However, when adding a relationship I have a duplication for "Content using [field_name]" and one of them works, while the other doesn't.
Setting this to "Needs work" according to comment 185.
Comment #188
spotzero commentedI've rebased the issue fork and it seems to work for me. I've not sure how the issue fork has diverged from the latest patch though.
Comment #189
attisan+1 for the MR 5.
Comment #190
abx commentedJust tested MR5 from #187 and it fixed this issue for me.
Thanks,
Comment #191
jchand commentedIs a patch available for comment number #187? thx
Comment #192
abx commentedI use composer, so, I use this link to patch -> https://git.drupalcode.org/project/entity_reference_revisions/-/merge_re...
Comment #193
jchand commentedThanks, abx. Seems to be working for me.
Comment #194
neograph734Setting NR for #187
Comment #195
socialnicheguru commentedWill update hooks be added to this issue or will that be another issue?
Comment #196
spotzero commented@SocialNicheGuru what update hooks are you referring to? It's been a while since I looked at this issue, but I didn't think it needed an update hook.
Comment #197
socialnicheguru commentedComment #124 outlines the need for update_hook as well as comment #125
This breaks old views when applied. I am experiencing this too.
Comment #198
socialnicheguru commentedUpdate 6-21-23:
When I goto admin/structure/paragraphs_type the paragraphs are there. I can edit them and save them, etc.
But suddenly they are not visible by views. None of my paragraphs are. Not even paragraphs created by other modules.
In #124 an update hook was referenced. I guess it might have been referring to content types not the views themselves.
The paragraphs can't be read by them.
We created a new paragraph to copy the content of the old paragraph and voila, the new paragraph is readable by views.
I tried opening and saving the old paragraph type. They still are not readable by views.
We are going to try deleting paragraph types and re-importing.
---
Drupal 9.5.9
MR 5 applied
php8.1
paragraphs 1.5
err 1.10
I am also having an issue.
My slideshow view has a relationship:
"paragraph referenced by slideshow_paragraph_ref"
slideshow_paragraph_ref is in my slideshow content type and points to slideshow paragraph type
I can add the new relationships fine.
When I try to then add fields from my specific paragraph the fields are not there. There is no reference to the specific paragraph type.
I do have access to generic paragraph fields:
Comment #199
socialnicheguru commentedComment #200
socialnicheguru commentedUpdate:
I did have to do that in order for the view fields and relationships to not be broken.
i also had to recreate my paragraphs.
The ones that i had are not seen.
---
Thank you #124
I had to goto my effected view
do a search and replace and add "_target_id" to ERR in my view
so field_paragraph became field_paragraph_target_id
I deleted the view
I had mine in a feature/config so did a drush features-import feature name you can do a config-import.
And all is good in the world again.
Comment #202
acbramley commentedI've pushed the missing filter plugin and tests to the MR.
To keep this issue sane and in any hope of getting committed, please do not post any more reroll patches of previous patches without tests, etc.
To generate a patch from the MR, you can do a
wget https://git.drupalcode.org/project/entity_reference_revisions/-/merge_requests/5.diffAnd commit the patch locally, you can reference a local patch in composer using
"my patch": "./path/to/file.patch"Comment #203
google01 commentedUnfortunately with the latest changes MR5 is causing problems and is not being applied correctly.
Comment #204
luenemann@google01 the MR !5 does not apply to a released version because
entity_composite_relationship_test.info.ymlis changed by drupal.org release packaging.As a solution you could switch to a git checkout of entity_reference_revisions like this:
composer reinstall --prefer-source drupal/entity_reference_revisions
Better use
Comment #205
robertoperuzzo@luenemann I run your first composer reinstall command, but the MR !5 still doesn't apply.
The second one (the update) works.
Comment #206
robertoperuzzoThe MR !5 patch works locally using the @luenemann advice, but it doesn't work in my CI/CD pipeline because we use the standard
--prefer-distflag in composer install command.Temporarily I install the dev-1.x version of the module.
Comment #207
google01 commentedAlthough not my first choice to use "dev" modules in production, you can apply the patch by replacing the stable version of the module in composer.json with:
"drupal/entity_reference_revisions": "1.x-dev",
For those of us who use modules like "paragraph" the integrity of this module is essential.
But it is always appreciated the tasks to improve the features of the contributed modules.
Comment #208
luenemann@robertoperuzzo You can set preferred-intall in composer.json config (https://getcomposer.org/doc/06-config.md#preferred-install) . Use
Comment #209
tobiasbIn case someone needs fix-only patch, which does not touch the info file. -> #3371284: Patches - entity_reference_revisions ;-)
Comment #210
anybodyBack to NW as of the failing tests in #201
Comment #211
geek-merlinNote: All failing tests boil down to:
Any idea how to fix this and move this forward? It it's in the comments or the IS, i did not see it.
Comment #212
berdirThat's because these tests don't have the views module enabled. Moving the config to config/optional should be enough to fix that.
Comment #214
b-prod commentedFixes the compatibility with PHP 8.2
There are 2 version, on declaring the property, the other creating a simple variable. The last version seems more logical, as the property is not used anywhere so it seems useless.
The patch uses the second variant.
Comment #215
b-prod commentedHere is the correct patch, the previous is invalid.
Comment #216
b-prod commentedThis is not my day... Here is the correct patch, I hope.
Comment #217
vasikeThis still not closed, after all these years ... hmm
Updated the MR to make it green
Used @Berdir #211 suggestion about the some errors.
+ Some new PHP issues that add errors for tests.
Also merged the latest dev version of module.
What else is needed here?
p.s. i think we need to use the MR, instead of patches - to join our efforts ... and maybe hide the patches.
Comment #218
capysara commentedI agree, the patches should be hidden and work should continue in the MR. Hiding patches.
There are several Remaining tasks in the IS that need to be reviewed. If they're already fixed, then the IS should be updated.
Comment #219
tonytheferg commentedSorry, patches are still helpful for some people.
Patch applied cleanly to latest dev.
I can now add reverse relationships to parent entities as expected.
If the Gitlab Ci is green, and the tests pass seems like we should be close?
Any word on what is needed still to get this added into a release?
Comment #220
s.kulyk commentedMR patch that is compatible with 1.10 module version. Works for me.
Comment #221
maenjuelI tried patch #176 and patch #219 and they both solved the issue so the referenced content showing up in views (#176 with an older, stable release of the module, and #219 with the latest dev release).
However, I'm not able to remove a paragraph from a view with either version/patch.
If I edit a node and remove a paragraph, the view still includes the removed paragraph. As a contextual filter I tested both "Paragraph revision: Parent ID" and "Paragraph: Parent ID" and added also tested with the filter criteria "Paragraph revision: Is Latest Revision", to see whether it makes a difference.
Unfortunately it didn't help and now I'm left with a "ghost paragraph".
EDIT 17.5.2024: After digging a bit deeper I realised I simply hadn't configure the relationship properly. The view has to be set up correctly so paragraphs from old node revisions don't show up anymore. Turns out my comment is unrelated and not a bug, but everything works as designed.
Comment #222
vensiresI personally think that this last comment is not related to the issue tackled here unfortunately.
Your issue seems to be that the there are still paragraph entities having as parent ID your host entity which - from a query perspective - is correct. Maybe your solutions lies on the functionality of paragraphs to remove orphaned paragraphs.
Comment #223
capysara commentedIndividuals can generate patches from Merge Requests. Having both patches and MRs in the queue, especially in an 8 year old issue with over 200 comments, will slow down progress.
For example, there's no MR (or interdiff) for #220 so changes are no longer being tracked, which makes it more difficult for someone to decide what to test. If the patch in #220 is different from the patch in #219, then the MR needs to be updated.
Comment #224
maenjuelHmm, you might be right @vensires, it could simply be related to the Paragraphs module. There are still some bug reports and forum posts about orphaned paragraphs, so that seems to be a thing.
I thought it might have to do with this issue since the node edit form doesn't list the (not anymore) referenced paragraph anymore (so the paragraph shouldn't be "related" to the host anymore) and "Delete orphaned composite entities" on /admin/config/system/delete-orphans didn't remove any paragraphs.
Comment #225
kyriazo commentedTested #220 and works as intended.
Comment #226
bubuAfter switching from D9.5 to D10.2 I updated patch from #158 to #220 and it works well again.
Comment #228
primsi commentedThis needed a rebase for me.
Comment #229
berdirHappy that this is close, I posted a review with a few things that should be fairly easy to address.
Comment #230
berdirDid some manual testing and this is quite challenging. I know a huge number of people use this and I wanted to get this merged, but it's a lot and complex.
Right now, the MR *attempts* to define a by-id and a by-revision-id relationship, both direct and reverse.
However, they have the same keys on the views data definitions, so in practice, only by-id is defined. By-id uses the "By id: " prefix in the label, which is really confusing to users IMHO, it certainly confused me and took me quite a long time to figure this out.
Additionally, it also defines by-id and by-target-and-host-revision-i references in a loop, which in practice results in _another relationship that does exactly the same and those really are visible duplicates, because they're defined on the respective column for views and not the field name.
My guess is that over time, things conflicted, were refactored and got copy pasted and merged resulting in this duplicated definition.
The problem is that both current by-id and the overwritten by-reference-id relationships from the base/data table are kind of wrong. If you have a situation where a default revision of a host entity references a non-default revision of a target entity, both relationships will always show the default revision, because by-revision-id really just joins through the revision table implicitly and will still use the default unless you specifically use fields of the revision relationship:
In practice, this should currently rarely happen, because ERR attempts to keep the default revision in sync for entities like paragraphs.
Still not entirely sure what to do with this. Possibly something like this:
* Regular reference to the target entity, replacing the current by-id relationship label
* New regular reference to the target entity *revision*, this will replace the currently overwritten one and will always be the correct data/revision, but revisions are a bit limited in views, you can for example apparently not render them.
* A single reverse relationship for both the default and the revision table. The default table will only show the host entity and the revision table will only show the host entity revision option. So the current "HostEntity revision using FIELD" relationship will go away when you have a view of TargetEntity (e.g. paragraphs) and not revisions, since per the query above, it's the same, just an doing an extra join.
This means that existing views relying on the patch might be broken as some relationships will no longer exist, not under their current identifiers anyway.
Comment #231
recrit commentedThe MR diff cannot be applied to a stable tag (i.e. 8.x-1.12) due to the changes in
tests/modules/entity_composite_relationship_test/entity_composite_relationship_test.info.yml. The attached patch does not include any tests changes so that it can be used in a composer build.Comment #232
delacosta456 commentedhi
i confirm the issue mentioned by @recrit . And it's provided patch #231 solve the issue for me
Thanks
Comment #233
leolandotan commentedI have tested the patch from #231 on a site with Drupal Core 10.3.8, Entity Reference Revisions 8.x-1.12 and Paragraphs 1.18 installed. I can confirm that this is fixed when I have added the "Articles with a field_paragraphs set to the Paragraph." relationship.
I just added a Paragraph field(field_paragraphs) to the Article content type and created a simple view showing Paragraphs with a Relationship and Contextual filter of "Parent ID (Paragraph)".
Thank you very much!
Comment #235
jayelless commentedWhen generating a views report involving paragraphs after upgrading to PHP8.3, I get the following error:
Convert the dynamic property "$this->first_alias" into a standard PHP variable "$first_alias", as it is not used anywhere else.
I have updated the existing merge request with this change.
Comment #236
vensiresJust to clarify, @jlscott's comment above is not out of scope; it's an issue introduced directly from the code of this MR as he described in #3492736-3: Deprecated function: Creation of dynamic property. It's not clear to me though - just be reading the comments at least - whether the points noted in #230 are addressed or not. Checking the code, I think it's still well set as "Needs work".
Comment #237
tyler.hastainThis patch in Comment #231 solved the problem for me as well.
Comment #238
arx-e commentedI didn't manage to apply the patch (5.diff or other) via composer with Drupal 11.1.1, but I did it manually (incorporating the changes in 6e180912) and my view seems to work just fine. Fetches fields from the referencing node and filters using those fields.
Comment #239
beatnikdude commentedPatch in Comment #231 solved the problem for me as well
Comment #240
junaidpvI confirm patch from comment #231 worked for me as well. Module version is 8.x-1.12.
Comment #242
patrickharris commentedThe patch from #231 is working for me as well. @berdir are there outstanding issues that still need to be addressed here?
Comment #243
uv516 commentedPatch from #231 is working for me as well.
Comment #245
joelpittetI was going to RTBC this but there seems to be a failing test... I will echo people above, #231 patch totally fixes the reverse relationship to the host. I was wondering why it thought vid was reasonable to match entity ids.