Fix label token replacement for views entity reference arguments

Created on 26 December 2015, over 8 years ago
Updated 21 June 2024, 6 days ago

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

  1. New installation with the standard profile
  2. create a node with a few tags
  3. create a content view, add field_tags as an argument.
  4. 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

  1. Reviews
  2. RTBC
  3. Commit / rejoice
  4. Unblock ๐Ÿ› [PP-1] Use labels in Views argument summaries for entity references Active 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.

๐Ÿ› Bug report
Status

Fixed

Version

10.3 โœจ

Component
Viewsย  โ†’

Last updated 1 minute ago

Created by

๐Ÿ‡ธ๐Ÿ‡ชSweden alayham

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • ๐Ÿ‡น๐Ÿ‡ทTurkey RgnYLDZ

    #148 ๐Ÿ› Fix label token replacement for views entity reference arguments RTBC did not apply with drupal 10.0.9 and PHP 8.1

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    This should work for 10.x

  • last update about 1 year ago
    28,526 pass, 2 fail
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Nathan Tsai

    #151 ๐Ÿ› Fix label token replacement for views entity reference arguments RTBC successfully applied for me.

    Will follow up if it breaks my website ;)

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Lendude Amsterdam

    The test failure is in one of the new tests, so that certainly needs fixing.

    +++ b/core/modules/views/views.post_update.php
    @@ -37,3 +39,33 @@ function views_removed_post_updates() {
    +function views_post_update_views_data_argument_plugin_id() {
    

    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!

  • Assigned to Alex Bukach
  • Status changed to Needs review 10 months ago
  • last update 10 months ago
    Patch Failed to Apply
  • last update 10 months ago
    Build Successful
  • ๐Ÿ‡จ๐Ÿ‡พCyprus Alex Bukach

    Rerolled #122 for 10.1.x and 11.x.

  • last update 10 months ago
    29,477 pass, 4 fail
  • ๐Ÿ‡จ๐Ÿ‡พCyprus Alex Bukach

    Selected correct version.

  • last update 10 months ago
    Build Successful
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update 9 months ago
    29,482 pass, 4 fail
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update 9 months ago
    29,653 pass, 4 fail
  • First commit to issue fork.
  • Pipeline finished with Canceled
    3 months ago
    Total: 143s
    #123310
  • Pipeline finished with Failed
    3 months ago
    Total: 184s
    #123313
  • Pipeline finished with Failed
    3 months ago
    Total: 474s
    #123321
  • First commit to issue fork.
  • Pipeline finished with Failed
    2 months ago
    Total: 177s
    #149885
  • Pipeline finished with Failed
    2 months ago
    Total: 990s
    #149884
  • Pipeline finished with Failed
    2 months ago
    Total: 986s
    #149894
  • Issue was unassigned.
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    I 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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Embedding the screenshots from #149 into the summary, too, so we don't need those from anyone else. ๐Ÿ˜…

    Thanks,
    -Derek

  • Pipeline finished with Canceled
    2 months ago
    Total: 305s
    #149928
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Pushed 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 ๐Ÿ› Return translated term name on views "Content: Has taxonomy term ID (with depth)" Fixed . 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.

  • Pipeline finished with Failed
    2 months ago
    Total: 570s
    #149941
  • Pipeline finished with Failed
    2 months ago
    Total: 1051s
    #149938
  • Pipeline finished with Failed
    2 months ago
    Total: 1167s
    #149940
  • Pipeline finished with Failed
    2 months ago
    Total: 165s
    #150091
  • Pipeline finished with Failed
    2 months ago
    Total: 188s
    #150100
  • Pipeline finished with Failed
    2 months ago
    #150099
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Addressed #153 and converted the post_update to use ViewsConfigUpdater. However, EntityArgumentUpdateTest.php was 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...

  • Pipeline finished with Failed
    2 months ago
    Total: 649s
    #150105
  • Pipeline finished with Failed
    2 months ago
    Total: 636s
    #150107
  • Pipeline finished with Failed
    2 months ago
    #150106
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Bumping this to major since I believe this qualifies under:

    Render one feature unusable with no workaround

    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.

  • Pipeline finished with Failed
    2 months ago
    Total: 568s
    #150133
  • Pipeline finished with Failed
    2 months ago
    Total: 1002s
    #150136
  • Pipeline finished with Failed
    2 months ago
    Total: 1011s
    #150137
  • Status changed to Needs work 2 months ago
  • The 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.

  • Pipeline finished with Running
    2 months ago
    #150529
  • Pipeline finished with Failed
    2 months ago
    Total: 1018s
    #150526
  • Pipeline finished with Failed
    2 months ago
    Total: 1171s
    #150527
  • Pipeline finished with Failed
    2 months ago
    Total: 1049s
    #150541
  • Pipeline finished with Success
    2 months ago
    Total: 1027s
    #150544
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Via Slack, @catch pointed me to ๐Ÿ“Œ Set budgets rather than exact numbers of asset size assertions Downport . 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...

  • Pipeline finished with Success
    2 months ago
    Total: 1136s
    #150588
  • Pipeline finished with Success
    2 months ago
    Total: 1144s
    #150589
  • Pipeline finished with Failed
    2 months ago
    Total: 1312s
    #150590
  • Pipeline finished with Success
    2 months ago
    Total: 1139s
    #150601
  • Pipeline finished with Success
    2 months ago
    Total: 1108s
    #150616
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Bah, 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:

    Installing Drupal
    In install.core.inc line 966:
                                                                                   
      Resolve all issues below to continue the installation. For help configuring  
       your database server, see the <a href="https://www.drupal.org/docs/install  
      ing-drupal">installation handbook</a>, or contact your hosting provider.<ul  
      ><li>The database server version <em class="placeholder">3.40.1</em> is les  
      s than the minimum required version <em class="placeholder">3.45</em>.</li>  
      </ul>                                                                        
    

    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

  • Pipeline finished with Failed
    2 months ago
    Total: 486s
    #150645
  • Pipeline finished with Success
    2 months ago
    Total: 1084s
    #150646
  • Pipeline finished with Success
    2 months ago
    Total: 1082s
    #150647
  • Pipeline finished with Failed
    2 months ago
    Total: 192s
    #150700
  • Pipeline finished with Failed
    2 months ago
    Total: 195s
    #150699
  • Status changed to Needs work 2 months ago
  • The 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.

  • Pipeline finished with Failed
    2 months ago
    Total: 175s
    #150711
  • Pipeline finished with Failed
    2 months ago
    #150720
  • Pipeline finished with Failed
    2 months ago
    Total: 166s
    #150722
  • Pipeline finished with Running
    2 months ago
    #150725
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    I 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 to EntityArgument, so it now supports all the old legacy ways it might be instantiated / used since it's replacing all the other core classes. Updated ViewsArgumentDeprecationTest to trigger all the new deprecations and check for the right ones. I think we should edit the CR from ๐Ÿ› Return translated term name on views "Content: Has taxonomy term ID (with depth)" Fixed ( https://www.drupal.org/node/3427843 โ†’ ) to only talk about IndexTidDepth since the Taxonomy one 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.

  • Pipeline finished with Success
    2 months ago
    Total: 1551s
    #150738
  • Pipeline finished with Success
    2 months ago
    Total: 990s
    #150753
  • Pipeline finished with Failed
    2 months ago
    Total: 1674s
    #150748
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Hrm, ๐Ÿ› [random test failure] Drupal\Tests\media_library\FunctionalJavascript\WidgetViewsTest::testWidgetViews random fail Fixed seems to keep happening, or a new problem has arisen, or something. But WidgetViewsTest is 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

  • Pipeline finished with Failed
    2 months ago
    Total: 190s
    #150826
  • Pipeline finished with Failed
    2 months ago
    Total: 181s
    #150827
  • Pipeline finished with Failed
    2 months ago
    #150831
  • Pipeline finished with Failed
    2 months ago
    Total: 508s
    #150838
  • Pipeline finished with Failed
    2 months ago
    Total: 993s
    #150837
  • Pipeline finished with Success
    2 months ago
    Total: 1079s
    #150844
  • Pipeline finished with Canceled
    2 months ago
    Total: 361s
    #151426
  • Pipeline finished with Canceled
    2 months ago
    Total: 262s
    #151429
  • Pipeline finished with Canceled
    2 months ago
    Total: 467s
    #151431
  • Pipeline finished with Failed
    2 months ago
    Total: 529s
    #151444
  • Pipeline finished with Failed
    2 months ago
    Total: 1019s
    #151440
  • Pipeline finished with Failed
    2 months ago
    Total: 989s
    #151445
  • Pipeline finished with Failed
    2 months ago
    Total: 224s
    #151454
  • Pipeline finished with Failed
    2 months ago
    Total: 241s
    #151465
  • Pipeline finished with Failed
    2 months ago
    Total: 541s
    #151463
  • Pipeline finished with Failed
    2 months ago
    Total: 1083s
    #151453
  • Pipeline finished with Failed
    2 months ago
    Total: 959s
    #151469
  • Pipeline finished with Success
    2 months ago
    Total: 989s
    #151501
  • Pipeline finished with Failed
    2 months ago
    Total: 510s
    #151512
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia kim.pepper ๐Ÿ„โ€โ™‚๏ธ๐Ÿ‡ฆ๐Ÿ‡บSydney, Australia
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Thanks for the reviews! Crediting kim.pepper and Lendude.

    Lendude asked about the difference between EntityArgument vs. EntityReferenceArgument. I wasn't sure. ๐Ÿ˜‚ It was introduced at comment #120. I tried to remove the distinction and make everything use EntityArgument, but then Kernel/ViewExecutableTest::testArgumentValidatorValueOverride() started failing (see pipeline job 1377453):

    1) Drupal\Tests\views\Kernel\ViewExecutableTest::testArgumentValidatorValueOverride
    Failed asserting that two arrays are equal.
    --- Expected
    +++ Actual
    @@ @@
     Array (
    -    '{{ arguments.uid }}' => '0I[">&1Z'
    +    '{{ arguments.uid }}' => ''
         '{{ raw_arguments.uid }}' => '1'
     )
    

    The test view argument definition ( see core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument_dependency.yml) seems weird:

            uid:
              id: uid
              table: node_field_revision
              field: uid
              relationship: none
    ...
              entity_type: node
              entity_field: uid
              plugin_id: numeric
    

    Why entity_type: node if this is pointing to a user? I don't fully understand the use of entity_type in 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_id not entity_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.

  • Pipeline finished with Failed
    2 months ago
    Total: 1112s
    #151511
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Opened ๐Ÿ› [PP-1] Use labels in Views argument summaries for entity references Active 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

  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Can the MRs be cleaned up?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Not 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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    11.x has consistent functional test failure.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Ahh, thanks. The 11.x MR was failing due to ๐Ÿ“Œ Remove the 9.4 database dump fixtures from 11.x Active . ๐Ÿ˜… 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. ๐Ÿคž

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Pipelines 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...

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    The 11.x branch needed a rebase (with some fairly trivial conflicts) due to ๐Ÿ“Œ Removed deprecated code in taxonomy module Fixed

  • Pipeline finished with Success
    2 months ago
    Total: 5138s
    #154665
  • Status changed to RTBC 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    @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.

  • Pipeline finished with Success
    2 months ago
    Total: 991s
    #154731
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Thanks for the reviews and RTBC! I pushed the bool return type to ViewsConfigUpdater::needsEntityArgumentUpdate() to both 10.3.x and 10.2.x MRs. Thanks for spotting that.

  • Pipeline finished with Failed
    2 months ago
    Total: 565s
    #154755
  • Pipeline finished with Failed
    2 months ago
    Total: 1024s
    #154754
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Pravesh_Poonia

    Applied MR-7572, it looks correct now

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone New Zealand
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    alexpott โ†’ changed the visibility of the branch 2640994-10_2_x-label-token-replacement to hidden.

  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    The 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.

  • Status changed to Needs review about 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Rebased the 11.x MR to resolve conflicts.

    @alexpott: Not sure what you mean with this:

    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.

    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

  • Pipeline finished with Success
    about 2 months ago
    Total: 1043s
    #160206
  • Pipeline finished with Success
    about 2 months ago
    Total: 533s
    #160216
  • Status changed to RTBC about 1 month ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    I asked in #bugsmash for help on this. @catch pointed me to ๐Ÿ“Œ ckeditor5 and editor module tests rely on hook_editor_presave() bc layers Active , 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:

    function views_view_presave(ViewEntityInterface $view) {
      /** @var \Drupal\views\ViewsConfigUpdater $config_updater */
      $config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
      $config_updater->updateAll($view);
    }
    

    @alexpott, are you proposing we should change the API for ViewsConfigUpdater::updateAll() to take a 2nd argument to determine if we're being called from presave or post_update? Or do you propose that views_view_presave() checks the return value from ViewsConfigUpdater::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

  • Pipeline finished with Failed
    about 1 month ago
    Total: 291s
    #173709
  • Pipeline finished with Failed
    about 1 month ago
    Total: 191s
    #173710
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 38s
    #173715
  • Status changed to Needs review about 1 month ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    I 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.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 176s
    #173714
  • Pipeline finished with Failed
    about 1 month ago
    #173716
  • Pipeline finished with Failed
    about 1 month ago
    Total: 187s
    #173722
  • Pipeline finished with Failed
    about 1 month ago
    #173726
  • Pipeline finished with Canceled
    about 1 month ago
    #173751
  • Pipeline finished with Failed
    about 1 month ago
    #173750
  • Pipeline finished with Failed
    about 1 month ago
    Total: 754s
    #173752
  • Pipeline finished with Failed
    about 1 month ago
    Total: 599s
    #173790
  • Pipeline finished with Failed
    about 1 month ago
    Total: 596s
    #173793
  • Pipeline finished with Success
    about 1 month ago
    Total: 621s
    #173821
  • Pipeline finished with Success
    about 1 month ago
    Total: 705s
    #173848
  • Pipeline finished with Success
    about 1 month ago
    Total: 698s
    #173850
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Wow, what a colossal PITA. ๐Ÿ˜† Guess it's good I jumped through all those hoops, since:

    1. There were indeed some test views with stale argument plugin definitions that needed to be manually fixed, including the view for testing this new functionality. ๐Ÿ˜‚
    2. EntityArgumentUpdateTest was 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, ViewsConfigUpdater process functions make a bunch of changes to handler config, then try to save the view, but that instantiates another ViewsConfigUpdater object (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

  • Status changed to RTBC about 1 month ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    I'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

    1) Drupal\Tests\views\Functional\Update\EntityArgumentUpdateTest::testViewsFieldPluginConversion
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'entity_target_id'
    +'numeric'
    

    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

    • catch โ†’ committed bb543187 on 10.3.x
      Issue #2640994 by dww, tduong, Alex Bukach, Berdir, ameymudras, catch,...
  • Status changed to Fixed 28 days ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Reviewed 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!

    • catch โ†’ committed 46fd5d2d on 10.4.x
      Issue #2640994 by dww, tduong, Alex Bukach, Berdir, ameymudras, catch,...
    • catch โ†’ committed 3006f2af on 11.0.x
      Issue #2640994 by dww, tduong, Alex Bukach, Berdir, ameymudras, catch,...
    • catch โ†’ committed 28dac554 on 11.x
      Issue #2640994 by dww, tduong, Alex Bukach, Berdir, ameymudras, catch,...
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Woo hoo! ๐ŸŽ‰ Thanks, @catch!!

    I got the follow-up ready if anyone following here is interested in reviewing (and hopefully RTBC'ing) that one:

    ๐Ÿ› [PP-1] Use labels in Views argument summaries for entity references Active

    Thanks again! Very happy to see this fixed.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    p.s. Added 10.3.x versions to the CR and published it:
    https://www.drupal.org/node/3441945 โ†’

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom darrenwh Bristol
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Closed ๐Ÿ› Exposed contextual taxonomy filter does not update title Closed: duplicate as a duplicate and moved over credit.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia pameeela
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    Is 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?

    -          plugin_id: numeric
    +          plugin_id: entity_target_id
    +          target_entity_type_id: user
    

    Tests pass at 10.3 but fail at 10.2 with

    Schema errors for __the_view_name_ with the following errors:
    display.user_page.display_options.arguments.uid.not
    missing schema,
    
    user_page.display_options.arguments.uid.target_entity_type_id
    missing schema
    

    More details on ๐Ÿ“Œ Fix: The update to convert "numeric" arguments to "entity_target_id" is deprecated Active

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Replied on ๐Ÿ“Œ Fix: The update to convert "numeric" arguments to "entity_target_id" is deprecated Active 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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    I 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?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    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?

    I 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:

    • If I ignore all deprecations when testing at 10.3 I cannot tell what needs to be fixed
    • If I do not ignore deprecations at 10.3 every phpunit test contains this deprecation warning and it is very hard to read through the noise to see the other deprecations.

    I am using the core ignore file in the gitlab CI job

    SYMFONY_DEPRECATIONS_HELPER: "ignoreFile=$CI_PROJECT_DIR/$_WEB_ROOT/core/.deprecation-ignore.txt"
    

    Maybe there is a way I could patch that file, or add more deprecations to ignore in a second file, or some other way?

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland Berdir Switzerland

    There 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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States 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 โ†’ :

    So my recommendation for right now is to leave your views using numeric, tell GitLab CI to ignore the resulting depreciation notices until youโ€™re ready to ship a release that requires at least 10.3.x, then you can convert your shipped views and reconfigure your pipelines to fail on depreciations (if thatโ€™s what you actually want). ๐Ÿ˜…

    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 leave everything in 10.3 so contrib can actually use the new thing when we get to 10.4?
    Silencing or just removing the deprecation in 10.3 seems ok yeah.

    So I opened ๐Ÿ“Œ Remove deprecation about Views argument config conversion from numeric to entity_target_id from 10.3.x Closed: duplicate 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

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024