Provide a hook to block tracking

Created on 1 February 2023, almost 2 years ago
Updated 28 February 2023, over 1 year ago

Problem/Motivation

Currently, the module tracks allRevisions() of an entity during batch/drush updates.

This can lead to unexpected results when users only expect the actually published version to be checked and do not care about revisions.

Note: when using together with entity usage, it is possible to only track usage by implementing hook_entity_usage_block_tracking and check if only the default revision is processed, but that is at the EU level,
while we might need this in other modules too implementing entity track plugins.

Steps to reproduce

For example: create node with some paragraphs.
Create new revisions of node.
See that new revisions of paragraphs are then also created.
Run entity track batch (have content en paragraphs enabled as entity types to be tracked).
See that entity track plugins are executed for all revisions of the pargraph.

Proposed resolution


Provide a hook to block tracking.

Remaining tasks

Code. Review. Test.

User interface changes


New hook.

API changes

New hook.

Data model changes

None.

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇳🇱Netherlands askibinski

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

Comments & Activities

  • Issue created by @askibinski
  • 🇪🇸Spain marcoscano Barcelona, Spain

    In my experience this might be tricky and potentially complex to implement.
    For example, in a scenario where the site is using content moderation, the last revision isn't necessarily the default, and when using workspaces (I know this might be a bit outdated, but in case it comes up again in the future), a non-default revision could even be "published" in a staging workspace, and just become published (and default) at an arbitrary future point.
    In those cases, I fear that determining what "editors would expect to track" might not be easily generalizable, and could cause confusion.

    How about we implement a similar mechanism of a hook/event that sites could implement to ultimately alter what gets tracked and what doesn't?

  • 🇳🇱Netherlands askibinski

    Good points, I will change the title since I actually meant the default (active) revision.

    I discussed this with SeanB yesterday and regarding content moderation: getting the default is a bit tricker but doable. But indeed: I'm not completely sure if messing around with the revisions will trigger entity track. Something to check.

    Regarding workspaces: I have 0 experience with workspaces and haven't seen a project with it in real life, so personally I would be completely fine with checking whether workspaces module is enabled and disabling this option for incompatibility.

    The hook is a good alternative. The only thing bothering me about it is that it would require coding on the user part. And I think that the scenario where you are only interested in the active revision is the 80% usecase which "normal" users would like to have?

    I'll give it a stab with an option to see if I encounter any dragons.

  • 🇳🇱Netherlands askibinski

    @marcoscano
    I think you might be right to do this in a hook. There are just too many variables on how people might have structured their content to do this reliably through 1 setting.

    For example, we would have to figure out for each entity whether its a "middle-layer" non-canonical content entity (like a paragraph) and then find out what the active revision is, which for a paragraph means getting the entity reference revision field of the top level entity because there is no way to reliably get this info from the paragraph itself (as far as I know).

    But that's only a paragraph example.

  • 🇳🇱Netherlands askibinski

    Also, isn't it a bit weird that tracking of revisions is only done during a batch update?

  • 🇳🇱Netherlands askibinski

    Here is simple patch, for testing this with tracking default revisions only.

  • @askibinski opened merge request.
  • 🇳🇱Netherlands askibinski

    Needs test though. See entity usage for a similar test. And we already have entity_track_test.module.

  • Status changed to Needs review over 1 year ago
  • Status changed to RTBC over 1 year ago
  • 🇪🇸Spain marcoscano Barcelona, Spain

    Looks good to me! Thanks for working on this.

  • Status changed to Fixed over 1 year ago
  • 🇳🇱Netherlands seanB Netherlands

    Looks good to me as well. Merged!

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

Production build 0.71.5 2024