Duplicate "revision_history" local tasks created

Created on 15 December 2023, 11 months ago
Updated 16 January 2024, 10 months ago

Problem/Motivation

As of 10.1, version_history aka "Revision" local tasks are created for any revisionable entity. This includes custom entities, contrib entities, etc that already had them added themself and results in duplicates. Let's fix that.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 1 hour ago

Created by

heddn Nicaragua

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

Merge Requests

Comments & Activities

  • Issue created by @heddn
  • Status changed to Needs review 11 months ago
  • πŸ‡¬πŸ‡§United Kingdom AaronMcHale Edinburgh, Scotland

    GitLab comment added.

  • Status changed to Needs work 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Could we add a test case that checks the tabs for any duplicates?

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    This includes custom entities, contrib entities, etc that already had them added themself and results in duplicates.

    I'm a bit confused by this because the version_history route didn't exist before ✨ Implement a generic revision UI Fixed was committed. It would be good to get some steps to reproduce here to show how duplicates are generated.

  • πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

    Example from Group:

    # From group.links.task.yml
    group.version_history:
      title: 'Revisions'
      base_route: 'entity.group.canonical'
      route_name: 'entity.group.version_history'
      weight: 20
    

    And \Drupal\group\Entity\Group

     *     "route_provider" = {
     *       "html" = "Drupal\group\Entity\Routing\GroupRouteProvider",
     *       "revision" = "\Drupal\entity\Routing\RevisionRouteProvider",
     *     },
    

    So any module that was using https://www.drupal.org/project/entity β†’ to already get revision goodies before core started supporting it is now seeing the version history show up twice. This is because core has:

    entity.version_history:
      title: 'Revisions'
      weight: 20
      deriver: 'Drupal\Core\Entity\Plugin\Derivative\VersionHistoryLocalTasks'
    

    Which will trigger even if you're not using \Drupal\Core\Entity\Routing\RevisionHtmlRouteProvider.

    In short: With Entity API (the module), people had to manually declare their local task, now core declares it a second time even if you're not using the revision routes provided by core.

    My suggested solution: In D10 only supply the local task if the entity class is using core's route provider or a subclass thereof. In D11, we remove that check and rely on contrib to remove their copy of the local task declaration.

  • heddn Nicaragua

    Actually, entity.module also had some features here, which I'm trying to remove over in πŸ› Remove duplicate version history local tasks (10.1+) Needs review . But we should still make the world a better place by trying to remove duplicates.

  • πŸ‡§πŸ‡ͺBelgium msnassar

    I think, we could also remove the hook node_local_tasks_alter here.
    see: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/node/...

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    I'm still not sure this is core's responsibility. It seems like the Entity module should handle this instead, which it looks like it is over in
    https://git.drupalcode.org/project/entity/-/merge_requests/28/diffs

    I'm confused by this:

    In short: With Entity API (the module), people had to manually declare their local task

    Because the MR above would suggest otherwise.

    Re #9 - that's something different and requires Node to use the generic revision UI, see the comment in that hook.

  • heddn Nicaragua

    Not all custom code uses contrib entity module. The place that gets the greatest visibility is in core.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Not all custom code uses contrib entity module. The place that gets the greatest visibility is in core.

    Yes but it's not core's responsibility to take into account what someone MIGHT have done in custom code or contrib (should we also detect duplicates for every single other derived local task, menu item, route, etc that core provides?).

    We've got the fix for entity API module, why did Group module implement it manually again? It seems to me like it's a much better fit for Group (and others) to do their own logic on whether to add the local task or not just like Entity module.

Production build 0.71.5 2024