Problem/Motivation
When using token replacement for a value coming from a view argument in a view area, for example if passing field_tags as an argument, both possible tokens produce the passed term id. The documentation says:
{{ arguments.field_tags_target_id }} == Content: Tags (field_tags) title
{{ raw_arguments.field_tags_target_id }} == Content: Tags (field_tags) input
Steps to reproduce
- New installation with the standard profile
- create a node with a few tags
- create a content view, add field_tags as an argument.
- create a text area header block, choose to use Use replacement tokens from the first row, then add both proposed tokens to the text area {{ arguments.field_tags_target_id }} {{ raw_arguments.field_tags_target_id }} in the preview area, supply 1 as argument, you should get the title of the tag, and the ID. You get two IDs.
Proposed resolution
Consolidate all the different entity argument plugins (a few of which handle title replacement correctly, most of which do not), into a single Drupal\views\Plugin\views\argument\EntityArgument. This base plugin correctly handles label replacement tokens.
This removes a bunch of (nearly) duplicate code, improves consistency and functionality, while reducing technical debt.
- MR !7091 is the 11.x version, clean and shiny
- MR !7571 is the 10.3.x version with a BC layer and deprecation tests
- MR !7572 is the 10.2.x version with a silent BC layer
Remaining tasks
Deal with validate-able config test failures?Ensure pipelines are green on all branches- Reviews
- RTBC
- Commit / rejoice
- Unblock #3442227: Use labels in Views argument summaries for entity references and fix that, too
User interface changes
There's no user-visible change in the backend views UI. But views that are configured to have titles with human-readable labels will see those labels, not the numeric IDs you currently see, regardless of which token you reference.
Before

After

API changes
Add Drupal\views\Plugin\views\argument\EntityArgument (ID: entity_id) to handle entity ID values that are directly part of an entity.
Add Drupal\views\Plugin\views\argument\EntityReferenceArgument (ID: entity_target_id) to handle entity ID values from an entity reference.
All of the following now simply extend the EntityArgument base with no other code:
- core/modules/file/src/Plugin/views/argument/Fid.php
- core/modules/node/src/Plugin/views/argument/Nid.php
- core/modules/taxonomy/src/Plugin/views/argument/Taxonomy.php
- core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php
- core/modules/user/src/Plugin/views/argument/Uid.php
A BC layer lives in the 10.x versions of EntityArgument to handle all the legacy ways these plugins were constructed or their protected properties accessed. See the change record for this issue for details.
Data model changes
New views_post_update_views_data_argument_plugin_id() goes through existing Views on the site that are configured to use a numeric argument plugin that points to an entity ID property and updates them to use the new entity_target_id plugin and set the target_entity_type_id option correctly.
Release notes snippet
When using a Views contextual filter (aka "argument") on an entity reference field, there is an option to override the title of the view using tokens based on the contextual filter value. There are separate tokens for the raw ID and the label of the entity that ID points to. These separate tokens did not work until Drupal version X. views_post_update_views_data_argument_plugin_id() is provided to update the configuration of any impacted Views on existing sites.
| Comment | File | Size | Author |
|---|---|---|---|
| #170 | 2640994-nr-bot.txt | 9.24 KB | needs-review-queue-bot |
| #167 | 2640994-nr-bot.txt | 90 bytes | needs-review-queue-bot |
Issue fork drupal-2640994
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
cilefen commentedBugs can be fixed in 8.0.x.
Comment #3
berdirExcept I'm not sure it's a bug, or where that bug is.
Yes it says title there, but this is about the *argument* title, not the term name. And it is whatever the argument plugin happens to implement, which I guess in this case, isn't much.
In short, it's not a token problem, that very likely returns correctly whatever the argument plugin's getTitle()/title() method returns.
Comment #4
alayham commentedHere is what the plugin does for title()
I don't think this method is called in this context.
I am not an expert in views or D8, but I believe there might be something bigger behind this bug.
Comment #5
dawehnerYeah for the custom integrations we had in d6/d7 there have been all kind of custom code. Now we deal with a generic entity reference field, I believe,
in which case there is no such integration. Maybe though for entity reference arguments we might want to provide that possiblity using
$entity->label().In case we want to get that route, we would also invent an update path which converts all the existing one to use the raw ID first.
Comment #6
berdirDiscussed this with @dawehner.
The mentioned code is only used for arguments on the taxonomy term table itself and the special node <-> term arguments.
This means we need a new special entity reference argument plugin that is set in core_field_views_data instead of the default numeric plugin which implements title similar to above.
Note that there's also titleQuery() in IndexTid which actually looks a lot better to me because it uses getTranslationFromContext(). We'll need a mix of those two. (a title() method that uses getTranslationFromContext()).
Comment #7
alayham commentedThanks Berdir and dawehner. This looks more complex that I first thought.
My workaround to get the term name of the argument is:
1- Add the term name as a field, you can keep it hidden, and you might need to add a relationship for that in some complex setups.
2- add a header component, set it to "Use replacement tokens from the first row". then use the token for the term name inside that header.
Using this workaround I managed to get the term name where I wanted it, except in the block or page title.
Comment #8
tduong commentedAdded new plugin EntityTargetIdArgument and implemented title() method.
Comment #9
berdirWe should add a comment to the $data that we're changing (something about providing a argument plugin that has a meaningful title() implementation.
We'll also need a test.
The only close thing that I could find is RolesRidArgumentTest, which uses a test_user_roles_rid test view.
We'll need something like that in taxonomy tests, with a node + term or so. Apparently we have no such test yet or we would have noticed when converting to entity_reference I guess.
Comment #10
tduong commentedExported the view previously created (manual token test worked). Providing test coverage using this test view, but somehow it does not properly call our plugin. As discussed with Berdir it may be a missing schema bug, I'll do it asap.
Comment #12
berdirIt doesn't work because the argument is broken and doesn't do anything. You always see all results.
That's because in your view, you used field_tags. That's from standard.profile. The test uses a different field name, see mockStandardInstall() in the parent. You need to update your view to use a field with that name.
Comment #13
tduong commentedFixed test with the suggestion above, added a check in form.inc since it seems there is a "PHP Notice" in core.
Comment #16
tduong commentedTest to be run after this #2665202: PHP Notice bug due to the recent #2595613 commit issue is committed.
Comment #17
dawehnerThis is looking pretty good. There are some remarks below.
What about adding some sane default value in
\Drupal\Core\Render\Element\Fieldsetinstead?This doc needs to have some fix.
What about implementing
titleQuery()instead and support multiple entity IDs by that automatically?Once we support more than one entity ID, we should also expand the test coverage with a multiple example.
Beside expanding views_views_inc I guess we also want to do the same stuff in
EntityViewsDatafor entity reference fields?Comment #18
tduong commentedFeedback for @dawehner from #17:
1. that won't be in this patch anymore, because it will be fixed by #2595613: '#title_display' => 'invisible' does not work for composite form elements (see #53)
2. I've checked in other files and edited it like Argument handler to accept an entity target id. or what do you suggest ?
3. I've tried to implement this title() to load multiple entities but it does not work. I'm not sure but I guess it's because as in the previous patch it uses only a single entity, the $titles array that I've returned in title() now is not valid with the required array in
Drupal\Core\Render\Element::children()or do I miss something ? How can I fix it ?4. wait for the point 3. to be done
5. I'm quite new with these stuff and I'm not sure what you want to be done in
EntityViewsData, can you give me some more details, please ?Test will fail since the related issue is not fixed yet.
Comment #20
dawehner@tim.plunkett, @effulgentsia @alexpott @xjm @cottser and @dawehner discussed that.
While we agreed that this is annoying, we don't think this is major, as it doesn't affect too many people. This doesn't mean we cannot fix it.
Thank you @tduong for heads up trying to fix it.
Comment #21
dawehnerWell I would have suggested to overload
titleQuery()instead.On top of that you are now using
TaxonomyTerm::loadMultiple(), better use$entity_storage->loadMultiple()Comment #22
tduong commentedRerolled. Uploaded patch:
break_phrase: trueallowing url with multiple values for the extended testEntityViewsDataPathPluginBaseis temporary because of a bug from a recent commit (#2598502: Double escaping in views attachment titles, see #14)Comment #24
tduong commentedPathPluginBase::getRoute()Comment #25
tduong commentedI've noticed that in a manual test for /entity-tid-argument-test/1+2 the title I get is test: title tax1 + tax2, input 1 2, while in the test the result is title tax1 + tax2, input 1+2. Does someone have any idea which one is the correct one and where it is processed ?
My local instance:
Comment #27
tduong commentedFixed test.
Comment #29
tduong commentedFixed PhpUnit test.
Comment #30
berdirThis would result in differences exported views as it has a different plugin_id. As we don't have any settings for either, nothing really breaks, but should we write and update function? Is that even possible? Just resaving doesn't help, not until we also fix #2648956: Editing a view leaves old keys hanging, results in invalid schema
I'm not sure about the name. I originally suggested this, but it's actually not really limited to the target_id column. Maybe EntityIdArgument or just EntityArgument?
Also, we have large list of argument classes that could either be replaced completely by this new generic argument plugin or at least extend from it (although some extend from others like ManyOne). Many of those are for example missing the translation context thing and would not be displayed in the right translation. An incomplete list:
* \Drupal\taxonomy\Plugin\views\argument\Taxonomy (is missing the translation context thing)
* \Drupal\taxonomy\Plugin\views\argument\VocabularyVid
* \Drupal\taxonomy\Plugin\views\argument\IndexTid
* \Drupal\taxonomy\Plugin\views\argument\IndexTidDepth
* \Drupal\user\Plugin\views\argument\RolesRid
* \Drupal\comment\Plugin\views\argument\UserUid
* \Drupal\node\Plugin\views\argument\Nid
We could make a follow-up for those, but if we have to update views configurations, it might be easier to just do them in one go?
minor coding standard issue there.
If we inject the entity type manager, then we should also inject entity.repository for this method.
Also, you should rename $terms and $term to $entities and $entity. It's no longer just about terms.
you should also check the new target_entity_type_id property that we're adding.
This comment should be updated and shortened and also duplicated into EntityViewsData.
Comment #31
tduong commentedRerolled.
1) discussed with berdir: wait for more details from @bedir and @dawehner
2) renamed class as EntityArgument/-Test, wait for more details for the rest
3-5) fixed
Comment #32
berdirDiscussed with @dawehner:
1. We need at least an update function that clears the views data cache. Views::viewsData()->clear();
2. We move this to a follow-up, please open one .
Comment #33
tduong commentedCreated follow up. Added views_update_8005() in views.install, just clear cache line, will work on this tomorrow.
Comment #34
dawehnerActually an empty update function is enough. The cache is cleared at the end anyway.
Comment #35
dawehner.
Comment #37
tduong commentedPainful rebase switching branch to 8.1.x... I saw that meanwhile an update_8005 function has been committed
so I guess it is enough also for us (?)
Let's see first if I've rebased everything right...
Comment #38
dawehnerI agree its not ideal.
But let's please keep this new update function, there might be people which ran their updates in the meantime.
Comment #40
tduong commentedSorry, do you mean that I should add also our update function, another empty views_update_8006() ?
Comment #41
berdirYes, exactly.
Comment #42
tduong commentedAdded empty update function 8102 since it is for 8.1.x-dev and it is supposed to be the second update function. Didn't change the number of the first one though to not to break anything.
Comment #44
dawehnerWe no longer needs tests, yeah!
Given that we change the used plugin ID, we should also reference that in the configured views ... as this is will be used for config schema validation, so we need a dedicated update function for that.
Comment #45
tduong commentedAdded an update function for configured views plugin ID with entity_reference field type.
Comment #46
dawehnerSorry :( I fear we aren't ready yet.
I'm a bit sceptical whether this actually works now ...
This code deals with base fields, but the update function deals with configurable fields. Do we need to do the same kind of change in
\core_field_views_data?Comment #49
tduong commentedhow should I fix it ?
actually we have already provided it in there:
or do you mean something else ?
Comment #50
dawehnerLol, I was indeed too lazy to scroll to the end of the patch. But still, you need to take into account base fields as well in your update hook.
Comment #51
berdirwe don't need an empty function if we also add a real update function. drop this and rename the other to 8102
this could be a bit more specific and specificy entity reference argument plugin IDs or so.
Yeah, that doesn't make sense :)
Whta you need to do instead is loop over the fields and inside, for each key, check if that is a field and if it is an entity reference field.
Not sure what the best way to do that is. Additionally, it is possible that someone is altering views data to something else.
Maybe we need to change this to a post update function and then compare it with the actual views data?
Comment #52
tduong commentedAaah ok, now I get what you meant.. still not sure how to fix it. I'll check it with @Berdir after lunch :)
Comment #54
tduong commentedAdded post_update (need implementation), tried to update the views data update function. Still work in progress...
Comment #55
tduong commentedMoved the update function code into the post_update one. Still cannot get the values I need to access the views data, tried to get the views through drupal_get_path() but it seems like there are no results for the modules we need (?) Can anyone help me, please ?
Comment #56
dawehnerlet's use entity label here, because this is not just about nodes.
I am confused
I think we want to iterate over all views using a similar method as above in that file:
This code example here would just update test files, not sure we really want that.
a) Don't you want to check for
'plugin_id'instead of'type'?b) IMHO we should apply these updates ALSO in the case when the configuration used to point to taxonomy arguments?
Comment #57
tduong commentedTrying to do some progress but still cannot get the data that I need... here is just my current test patch
Comment #59
tduong commentedJust a reroll. No conflict encountered.
Comment #61
berdirOk, trying to get this back on track. Cleaned up the update code, something like this should work but we have no test view, need to ensure one exists first.
Comment #63
berdirdoes it apply with 8.2?
Comment #64
berdirComment #66
berdirHere's a test using a similar test view as the one already added but using the existing field_tags field, also renamed a bunch of stuff.
Comment #67
dawehnerNice work in general!
Can we open a general followup to address the fact that entity types might have string IDs?
I'm wondering whether this should take into account the 'rendering_language' settings in tviews.
Hyper-nitpick: two empty lines
This seems out of scope now.
Comment #68
berdir1. Sure, we can ;) Should we name this class EntityArgumentNumeric then, so we can add an EntityArgumentString later?
2. I had a quick look but I think that is not possible. \Drupal\views\Entity\Render\EntityTranslationRendererBase::getLangcode() depends on a result row, we don't have that here. We could pick th first, but that could be entirely wrong. That entity might not have a translation but the term does. I think this is fine for now.
3. Oh no! How could I? :)
4. I love how dreditor manages to end up with 8x "core/modules/views/views.install" in that snippet ;)
I'm still unsure about doing #30.2 here (using this new class in those existing classes to avoid duplicate code) or not. But I'm going to try that now, we can still move it to a follow-up.
Comment #69
berdirImpressive how much duplicate code we have in those argument plugins. This just removes the code, we could also officially deprecate them and switch the code that specified them directly to entity_target_id (which as this shows, doesn't really make sense anymore as a name).
Most of those plugins are actually used for the ID field of the base table. Which is something that we could now do generically as well. But again, definitely risking going too far here. Deleting all that code is just so much fun. There are even a few more, that could use a string version (RolesRid, Type in node, VocabularyVid is actually incorrectly extending from NumericArgument).
PS: My personal favorite is Fid::titleQuery().
Comment #72
jonathanshawComment #73
jofitzI'll take a look at this...
Comment #74
jofitzRe-rolled.
Comment #75
jonathanshawCould you add interdiff?
Comment #76
jofitzIt is not possible to create an interdiff because it is a relatively complicated re-roll.
Also I managed to forget the new array syntax [] so here's another patch (with an interdiff for this change).
Comment #80
Ben Buske commentedrerolled for 8.4.0
Comment #83
lukasss commentedI think the issue is more global than just taxonomy.
I have nowhere this is not working.
I have to do as recommended here:
https://drupal.stackexchange.com/questions/205758/how-do-i-override-the-...
Comment #84
Ben Buske commentedreroll for 8.5. Sorry, I lost track of this ticket.
Comment #86
feyp commentedReroll of #84 for 8.6
Comment #87
cbrody commentedThis is still an issue in 8.7.4; the patch in #86 results in
Comment #88
lukasss commentedComment #91
colanUpdated title, as this applies to all entity references (not just taxonomy).
#87: The problem with #86 is that it's missing all of the new files so it's a bad patch. I'm not sure which would be easier:
I'd be inclined to start with #84 because it seems more trustworthy.
Related: I postponed #2912332: Allow entity reference views arguments to display the entity label in titles and summaries on this one.
Comment #92
nikitagupta commentedComment #93
nikitagupta commentedRerolled patch #84
Comment #95
colan#93: Thanks for working on this! Which patch are you working from?
If possible, please provide interdiffs. I know this may not always be possible due to different baselines.
Comment #96
nikitagupta commentedComment #97
nikitagupta commented@colan worked on #84 and interdiff is not possible due to different core versions.
Comment #98
osopolarThere is a workaround in #7.
Another way to work around the problem might be using preprocess hooks. For example, to set the node title in a views block on a node page. I guess, for taxonomy it would be similar.
Comment #100
raman.b commentedNot sure why
ViewExecutableTest::testArgumentValidatorValueOverrideis failingComment #101
raman.b commentedComment #102
raman.b commentedComment #104
fernly commentedTested with Drupal 9.1.10:
Patch #93: working
Patch #101: not working
Comment #105
chrisgross commentedHas anybody been able to successfully get this patch working on 8.9? I've tried to re-roll it myself, and it does apply, but I keep getting the following error when I try to view a page with a contextual filter:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of /var/www/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).This is a really frustrating bug that I need to fix but we're not quite ready for D9 yet. I haven't had luck with any workarounds.Comment #106
chrisgross commentedHas anyone successfully tested this on 9.2? The latest patches do not apply, but even after I manually update the files that failed to patch and then run update.php, this is still not working for me. My title arguments ( arguments.field_tags_target_id ) in views are still rendered as ids.
Comment #107
chrisgross commentedA sample workaround for this until it gets fixed might look like this. In this example, I want to display the tag name in a text area if my view shows no results. Since views is rendering the tag id instead of the name like it's supposed to, I have to load the term name and replace the entire token with it. This is pretty sloppy, but it works. Hopefully this bug can be fixed. Currently, any views designed this way in 7 will not work in 8/9.
Comment #108
catchStraight re-roll since this no longer applied to 9.3.x. Haven't reviewed yet.
Comment #109
catch9.2.x version for manual testing.
Comment #110
catchAnother re-roll.
Comment #113
volker23 commentedPatch from #110 does not apply anymore on 9.3.2.
Comment #114
alex.bukach commented@catch @raman.b could you guys explain why you started using
$this->definition['entity_type']as entity type instead of$this->definition['target_entity_type_id']? Looks liketarget_entity_type_idis the actual referred entity type whileentity_typeis the base entity type, and till #93target_entity_type_idwas used.Comment #115
ankithashettyRerolled the patch in #110, thanks!
Comment #117
alex.bukach commentedIn view of my notes above here's a re-roll of Berdir's patch #69.
Comment #120
alex.bukach commentedProbably the issue is that there are two type of arguments: entity ID (like "nid") and referred entity ID (like e.g. "field_term_target_id"). The initial patches tried to handle the second case, then patches tried to handle the first case. Looks like we should have handle these two cases separately using two different argument types. Here's an attempt to do that.
Comment #122
alex.bukach commentedComment #123
alex.bukach commentedComment #124
el1_1el commented9.3.x in 123 working for me. Thanks!
Comment #125
chrisgross commentedI can also confirm that the patch in #123 does finally work as well.
Comment #127
MihaiMiculescu commentedThis may or may not be right on the spot, but at least related.
I'm on Drupal 9/Commerce Kickstart 3 installed in Romanian only.
I created a view showing product variations only (entities, not nodes) that bear all the same tag. It's a page with the address
/taxonomy/term/%I got inspired by this comment and came up with this no-code solution :
-Added a hidden field with the tag rendered as label and link to the product variation.
-Then, in Relationships, I added the relationship between tag name and tag ID. Marked as required.
-In the contextual filter I enabled the use of the relationship. This triggered the availability of
{{ arguments.tid }}for me to use for overwriting the page title, while using tag ID as validation criterion.And voilà, the tag name instead of tag ID appears in the page title.
I just hope that sharing with you my perspective as a user, not developer, helps.
Comment #128
nicxvan commentedThe most recent patch applies but does not work for me on 9.4.5
Comment #129
technoveltyco commentedI confirm that the patch #122 applies correctly and fix the issue in Drupal Core 9.4.5.
I tested it in a view block that requires to display the author name in its title. The view has a contextual filter of the author field and it is setup to use the token to resolve from the content id to the node title as shown in the attached screenshot
Thanks @alex-bukach
Comment #130
technoveltyco commentedComment #131
quietone commentedThe issue summary here is simply a statement of the problem. The patch is > 40K and adds schema and a post_update function so let's have a description of the changes in the IS. I see an after screenshot in #129 so it seems that before and after screenshots should be added to the Issue Summary as well. I have added the standard template so it can be completed.
comment #128 states that the patch does not work on Drupal 9.4.5 so it does not seem ready for an RTBC.
Comment #132
quietone commentedComment #133
ameymudras commentedPatch 122 didn't apply correctly, I have re rolled the patch for 9.5.x
Comment #134
alex.bukach commented@ameymudras I did not check your patch thoroughly, but the last lines in the patch definitely should be inside a loop (like in #122) while they are outside in your patch. Could you please check it and attach interdiff?
Comment #135
anchal_gupta commentedFixed custom command failed error. please review
Comment #136
alex.bukach commented@Anchal_gupta both yours (#135) and @ameymudras (#133) patches contain issues I pointed out in #134. Could you please fix them and attach an interdiff between your patch and #123?
Comment #137
ameymudras commentedThanks @Alex, I have fixed the issue and fixed phpcs issues
Comment #139
pameeela commentedPatch in #122 worked for me on 9.4.7. No manual steps required, just applied the patch.
Before:

After:

Comment #141
nicxvan commentedThe patch in 137 works for me
Comment #142
ravi.shankar commentedAdded reroll of patch #137 on Drupal 10.1.x.
Comment #143
pradhumanjain2311 commentedTry to fix cs errors.
Comment #144
ameymudras commentedTrying to fix the above issue
Comment #145
ameymudras commentedMy working branch was out of sync which caused the above error, trying to fix the same
Comment #146
ameymudras commentedFixing phpcs issue with the above patch
Comment #148
ravi.shankar commentedTried to address tests of patch #146.
Comment #149
rgnyldz commented#148 did not apply with drupal 10.0.9 and PHP 8.1
Comment #151
nicxvan commentedThis should work for 10.x
Comment #152
nathan tsai commented#151 successfully applied for me.
Will follow up if it breaks my website ;)
Comment #153
lendudeThe test failure is in one of the new tests, so that certainly needs fixing.
Ideally this should use the ViewsConfigUpdater and the update patterns used for that, so we also update any newly imported Views coming from modules and install profiles
But this is looking pretty great otherwise!
Comment #154
alex.bukach commentedRerolled #122 for 10.1.x and 11.x.
Comment #155
alex.bukach commentedSelected correct version.
Comment #162
dwwI keep running into this bug. Due to attributes vs. annotations, this doesn't backport cleanly, so I opened new branches and MRs for 10.3.x and 10.2.x. Meanwhile, hiding all the old patches in favor of the 3 MRs.
I updated the summary. Hope that's clear enough for review.
Haven't looked into pipeline failures, so leaving at NW.
Let's get https://git.drupalcode.org/project/drupal/-/merge_requests/7091 passing ASAP. I can backport appropriate changes to the other branches / MRs. But they're here for now for other folks like me that need these fixed on 10.2.x sites.
Comment #163
dwwEmbedding the screenshots from #149 into the summary, too, so we don't need those from anyone else. 😅
Thanks,
-Derek
Comment #164
dwwPushed a few more commits to hopefully get more of the pipeline stages passing.
Meanwhile, one of the test failures is a new deprecation test added for #2765297: Return translated term name on views "Content: Has taxonomy term ID (with depth)". Since we haven't shipped 10.3.x, can we remove that test entirely? This is probably a sign we need to be more careful about BC? Adding as related.
Comment #165
dwwAddressed #153 and converted the post_update to use
ViewsConfigUpdater. However,EntityArgumentUpdateTest.phpwas still failing locally. Then determined that the fixture that test is using was based on a stale Views schema. I re-created the fixture view on a clean 10.2.x site, and now that test is passing locally. Pushed fixes to all branches. Let's see what the bot thinks now...Comment #166
dwwBumping this to major since I believe this qualifies under:
https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-...
The entire feature of setting display titles based on argument values converted to labels is broken, and AFAICT there's no workaround.
Comment #167
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #168
dwwVia Slack, @catch pointed me to #3441844: Set budgets rather than exact numbers of asset size assertions. Rebased the 11.x and 10.3.x MRs so hopefully that should solve the FunctionalJS failures so far. 🤞
Meanwhile, I started a draft CR: https://www.drupal.org/node/3441945
Back to NR...
Comment #169
dwwBah, the validatable config job is such a PITA. For a few weeks, it was failing to find a valid version of drush to install. Now it's complaining about this:
I don't have time for this. 😂 I'm going to ignore that for now, and I hope everyone else does, too. Crossing that off from the summary.
So this is really ready for review now. Would love to see this finally smashed, ideally for 10.3.x. I suspect this is probably too potentially disruptive for a 10.2.x backport, but I'm going to keep that MR up to date since I definitely need this working on some 10.2.x sites.
Thanks!
-Derek
Comment #170
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #171
dwwI don't know what the bot is doing, but it's confused, so turning it off from this issue.
I realized we don't want to remove
ViewsArgumentDeprecationTest, we want to fix it. 😅 I moved the deprecation dance toEntityArgument, so it now supports all the old legacy ways it might be instantiated / used since it's replacing all the other core classes. UpdatedViewsArgumentDeprecationTestto trigger all the new deprecations and check for the right ones. I think we should edit the CR from #2765297: Return translated term name on views "Content: Has taxonomy term ID (with depth)" (https://www.drupal.org/node/3427843) to only talk aboutIndexTidDepthsince theTaxonomyone is now gone.The 10_2_x version safely handles all the legacy stuff but throws no deprecation notices.
Meanwhile I updated the CR here with the full explanation of all the new BC stuff: https://www.drupal.org/node/3441945 Updated the API changes section of the summary.
Comment #172
dwwHrm, #3317378: [random test failure] Drupal\Tests\media_library\FunctionalJavascript\WidgetViewsTest::testWidgetViews random fail seems to keep happening, or a new problem has arisen, or something. But
WidgetViewsTestis randomly failing a lot right now, both on the bot, and locally, with or without this MR branch checked out. 😢Hopefully that doesn't turn into a huge time-sink.
Meanwhile, I opened 1 thread (in 7091) about the only thing left in this MR that I'm concerned about. Feedback and reviews most welcome. I think we're darn close to RTBC now. 😅 Phew!
Thanks,
-Derek
Comment #174
dwwThanks for the reviews! Crediting kim.pepper and Lendude.
Lendude asked about the difference between
EntityArgumentvs.EntityReferenceArgument. I wasn't sure. 😂 It was introduced at comment #120. I tried to remove the distinction and make everything useEntityArgument, but thenKernel/ViewExecutableTest::testArgumentValidatorValueOverride()started failing (see pipeline job 1377453):The test view argument definition ( see
core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument_dependency.yml) seems weird:Why
entity_type: nodeif this is pointing to auser? I don't fully understand the use ofentity_typein existing definitions...So maybe it's safer (if a little clumsy) as two separate plugins. Although should one extend the other? Or perhaps we could use one plugin, but make sure it uses
target_entity_type_idnotentity_type?For now, reverted the commits to unify the two, and instead pushed docs for both. All the relevant tests are passing locally again. The bot agrees, phew.
Meanwhile, per @catch in #d11readiness the 11.x branch is really 11.x now. We definitely need the separate MRs here. I cleaned up the 11.x MR to remove the deprecation tests and BC layer from
EntityArgument. All that only lives in !7571 now. The 10.2.x MR (!7572) has the silent BC layer.Comment #175
dwwOpened #3442227: Use labels in Views argument summaries for entity references to help resolve the last of the threads, keep the scope smaller in here, and finish the job that was started at #2912332: Allow entity reference views arguments to display the entity label in titles and summaries.
I believe this is RTBC, but obviously someone else will have to say so at this point. 😂
Thanks!
-Derek
Comment #176
smustgrave commentedCan the MRs be cleaned up?
Comment #177
smustgrave commentedComment #178
dwwNot sure what you mean. The ones I opened are very clean. 😂 I don’t have edit access to 7091, so the title and description are lacking, but does that matter? The summary explains what all 3 are for.
Comment #179
smustgrave commented11.x has consistent functional test failure.
Comment #180
dwwAhh, thanks. The 11.x MR was failing due to #3442172: Remove the 9.4 database dump fixtures from 11.x. 😅 Pushed a commit to use the 10.3.0 fixture instead of 9.4.0. That works locally in the 10.3.x MR. My local can't run 11.x ATM. 😂 Also rebased both MRs to latest 11.x and 10.3.x core. We should be all green again. 🤞
Comment #181
dwwComment #182
dwwPipelines are all green again, except the functional JS random fail in the 10.2.x MR mentioned above. I doubt the RMs are actually going to backport this to 10.2.x, and that MR is mostly for folks to patch their own live sites with until 10.3.0 is out and they can upgrade to it...
Comment #183
dwwThe 11.x branch needed a rebase (with some fairly trivial conflicts) due to #3442365: Removed deprecated code in taxonomy module
Comment #184
smustgrave commented@dww posted about this in #bugsmash so came here.
So following the steps to reproduce I was able to see the issue at hand.
Ran the test-only feature, large output so won't paste here, but here's the link https://git.drupalcode.org/issue/drupal-2640994/-/jobs/1409783
Applied a small nitpicky suggestion for a return type.
Applying the MR the issue does appear to be addressed.
The 1 thread got a response, so believe this is good to go.
Comment #185
dwwThanks for the reviews and RTBC! I pushed the
boolreturn type toViewsConfigUpdater::needsEntityArgumentUpdate()to both 10.3.x and 10.2.x MRs. Thanks for spotting that.Comment #186
pravesh_poonia commentedApplied MR-7572, it looks correct now
Comment #188
quietone commentedComment #190
alexpottThe 11.x MR needs work due to changes in the ViewsConfigUpdater... I think we need to trigger deprecations from the ViewConfigUpdater when it is fixing a view during preSave that's not done as part of the post update. This way modules will know that they have to update their shipped content.
Comment #191
dwwRebased the 11.x MR to resolve conflicts.
@alexpott: Not sure what you mean with this:
Sounds like scope creep to me. I don't want to be rewriting ViewConfigUpdater to add new functionality like this to try to fix this bug. Can we address that in a follow-up?
Thanks,
-Derek
Comment #192
dwwI asked in #bugsmash for help on this. @catch pointed me to #3442395: ckeditor5 and editor module test config exports/stubs rely on hook_editor_presave() bc layers, but that issue has nothing to do with
ViewsConfigUpdater. I still don't exactly understand what's being asked of me.Views is doing this:
@alexpott, are you proposing we should change the API for
ViewsConfigUpdater::updateAll()to take a 2nd argument to determine if we're being called frompresaveorpost_update? Or do you propose thatviews_view_presave()checks the return value fromViewsConfigUpdater::updateAll()and if it ever gets back TRUE it should always trigger a deprecation?Can we pretty please move all such complications to a dedicated follow-up, and fix this before the 10.3.0-beta1 ships? I still fail to see why this poor bug needs to be the one to deal with all that additional functionality.
Tentatively moving back to RTBC to get more committer eyes on this.
Thanks,
-Derek
Comment #193
dwwI got a bit more clarity from @catch on what's expected here. I pushed some commits to the 11.x and 10.3.x MRs to trigger deprecations when
ViewsConfigUpdater::processEntityArgumentUpdate()changes a view outside of post_update. I'm not sure on the wording of the deprecation message, that could use another pair of eyes. Also unclear if we "need" tests that this deprecation plumbing works as expected. I sure hope that's not my responsibility here. 😅I'll keep an eye on the pipelines to make sure I didn't break anything, but I hope this is now actually RTBC.
Comment #194
dwwWow, what a colossal PITA. 😆 Guess it's good I jumped through all those hoops, since:
EntityArgumentUpdateTestwas making some slightly bogus assertions.However, I had to completely rewrite
ViewsConfigUpdater::processEntityArgumentUpdate()to operate on entire View entities, instead of using all the per-handler plumbing we've got. To my great dismay, if you copy the existing patterns,ViewsConfigUpdaterprocess functions make a bunch of changes to handler config, then try to save the view, but that instantiates anotherViewsConfigUpdaterobject (this time, with deprecations enabled) to do all the work again. 🤯 So apparently, The Right Way™️ to update a view with all this plumbing is that your process function has to directly update the$view(which isn't even normally passed in to your process function if you think you're just dealing with handlers), not just fix the$handler. 🤦♂️I guess I'm now in the exclusive club of ~5 people on Earth who understand how this class works. 😬 😂
ANYWAY, we're back to green pipelines on 11.x and 10.3.x. I've given up on the 10.2.x MR at this point. It works great for the project where I needed this fixed, all the additional hassles are irrelevant to that site, and this is clearly not getting backported. I just hope this can still land in 10.3.x!
Thanks,
-Derek
Comment #195
smustgrave commentedI'd be lying if I said I fully understand the view config update (not one of the 5 haha) but running the test-only feature the tests for the update are failing as expected
Can see the full list of expected test failures here https://git.drupalcode.org/issue/drupal-2640994/-/jobs/1604882
So believe the addition of that is good
Comment #198
catchReviewed this all again:
- constructor deprecations in plugins in the 10.3 branch for removal in 11.x - this is OK during beta given it's plugin constructors to fix a major bug.
- config bc layer has a deprecation in 10.3 for removal in 12.x - this is good since it will make the bugfix non-disruptive for contrib modules.
Also thanks for the work on the config deprecation layer, hopefully we can do this correctly for all config updates from now onwards.
Committed/pushed to 11.x and cherry-picked back through to 10.3.x, thanks!
Comment #203
dwwWoo hoo! 🎉 Thanks, @catch!!
I got the follow-up ready if anyone following here is interested in reviewing (and hopefully RTBC'ing) that one:
#3442227: Use labels in Views argument summaries for entity references
Thanks again! Very happy to see this fixed.
Comment #204
dwwp.s. Added 10.3.x versions to the CR and published it:
https://www.drupal.org/node/3441945
Comment #206
smustgrave commentedClosed #3087020: Exposed contextual taxonomy filter does not update title as a duplicate and moved over credit.
Comment #207
pameeela commentedComment #208
jonathan1055 commentedIs there a follow-up issue for how to fix contrib tests that are now broken when the views .yml definition is updated to use the new plugins?
Tests pass at 10.3 but fail at 10.2 with
More details on #3451750: Fix: The update to convert "numeric" arguments to "entity_target_id" is deprecated
Comment #209
catchReplied on #3451750: Fix: The update to convert "numeric" arguments to "entity_target_id" is deprecated but also this is a general problem and one we might hit more often as config validation improves so it'd be good to document the outcome somewhere.
Comment #210
dwwI also replied there. But for here, TL;DR: the problem isn’t really about strict schema validation. It’s that the plug-ins do not exist in 10.2.x. So until folks can drop 10.2.x support, they’ll have to live with the deprecation warnings in 10.3.x and up that the auto-conversion will be dropped in 12.0.x.
Should we do a quick follow up to silence this deprecation in 10.3+ so folks don’t have to worry about it until they’re on 11.x?
Comment #211
jonathan1055 commentedI think that would be a very good idea, because currently this is preventing testing at 10.3. The default views provided by a contrib project are loaded in every phpunit test, not just the tests which use the views. So I currently have the scenario which I think is wrong on both sides:
I am using the core ignore file in the gitlab CI job
Maybe there is a way I could patch that file, or add more deprecations to ignore in a second file, or some other way?
Comment #212
berdirThere are many new deprecations in 10.3. They are added continuously to the next minor version. You can't expect to be deprecation free for the next minor version, or even the current version if you want to keep support for earlier versions. Sometimes there are workarounds, with if/else constructs, DeprecationHelper and what not, but for some deprecations, that just not possible or only with a lot of effort (you could probably do some magic at config install time if you find a hook/event/wrapped service that's early enough)
That's not a problem, that doesn't need to be fixed. There are no expectations to be deprecation-free at any point, it's an early warning system that something will change in the future, nothing is broken yet. There is a reason that deprecations are off by default in Gitlab CI.
Trying to keep next* test runs deprecation free is just a continuous race against Drupal core development. The only thing you can reliably go for is to be deprecation free on the oldest version you provide support for.
Comment #213
dww@berdir: Re #212: That's an extremely compelling case for why trying to "chase HEAD" is a headache. Quoting my advice to @jonathan1055 at #3451750-9: Fix: The update to convert "numeric" arguments to "entity_target_id" is deprecated:
However, I'm somewhat torn. You can't conditionally include different .yml in your views config based on versions. There really is no work-around if you want to try to keep up. There's 0 harm in silencing this deprecation in 10.3.x -- folks have years to learn about it and switch. I'm a big fan of making it as easy as possible to be as compatible with as many versions as possible, since ultimately, that's best for end users.
When I pinged @catch in Slack about this (before your comment), he replied:
So I opened #3453318: Remove deprecation about Views argument config conversion from numeric to entity_target_id from 10.3.x with a green MR so we can make things easier before the 10.3.0 final release.
Let's continue to discuss there, if necessary, and let this giant issue finally go silent for the 90 followers that only wanted their entity reference arguments to work. 😂
Thanks!
-Derek
Comment #215
codebymikey commentedOne thing of note is that this change breaks existing view definitions of certain argument plugins like
file_fid, node_nid, taxonomy, vocabulary_vid, user_uidwhich directly extend the NumericArgument plugin.Their
hook_views_data()argument definition might not include theentity_typeproperty, and triggers an exception to be called when it tries to fetch the title of the node.I'll open a follow-up issue for this.
Comment #216
saxmeisterThat is the issue that I am dealing with in 10.3, codebymikey.
Now that the
hook_views_data()argument definition doesn't includeentity_typesome of my Views are breaking and causing WSOD - especially using Leaflet in Views.The warnings I get are:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 142 of /data/drupal/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).Warning: Undefined array key "entity_type" in Drupal\views\Plugin\views\argument\EntityArgument->titleQuery() (line 75 of /data/drupal/web/core/modules/views/src/Plugin/views/argument/EntityArgument.php)Note the empty value of entity type. And since the entity doesn't have a value, the titleQuery() function cannot retrieve a value.
The Drupal site using a View that displays a Leaflet map and uses the Contextual Filter "Provide default value" with the option "Content ID from URL" to grab the latitude and longitude values to feed to this View.
Comment #220
xjmAdding missing credits for issue triage per #20:
For those posting comments more recently, this issue was closed over a year ago, and as a result, maintainers will generally not see your replies. You're better off opening new issues in the core queue referencing this one. Thanks!