Add revision support to products and product variations

Created on 26 January 2016, almost 9 years ago
Updated 23 August 2024, 3 months ago

We removed revisions from products and product variations when it became obvious we'd need to rewrite all of the core revision (UI) code ourselves, and because syncing revisions between a product and variations would be difficult.

Since then several things have started happening:
1) The Entity API module has been created and is getting the generic revision code
2) Entity Reference Revisions is now a module that handles the syncing between nested entities.
3) Multiversion will allow revisionable entities to be deployed, etc.

In order to benefit from #3 we need to integrate #1 and #2. Marking as postponed so that those modules have more time to mature. We can revisit in mid-Feb.

Warning: using these patches may cause problems when you want to revert back to a situation without revisions. Drupal core does not (yet) support entity updates which revert back to a situation without revisions. To do this you need to patch/hack core to do this, copy tables of all non revision tables, than execute entity updates, move tables back.

Remaining tasks

Add revision support to the entities.
Update script to convert existing sites.
Test coverage for product revisions.
Test coverage for product variation revisions.

📌 Task
Status

Needs work

Version

3.0

Component

Product

Created by

🇷🇸Serbia bojanz

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.

  • 🇺🇸United States DamienMcKenna NH, USA

    I don't think the work here needs to be paused until #3323788 is done, that's just a bug fix to one tiny part of the system.

    I think it would be worthwhile to identify all of the pieces necessary in the issue summary, including each test scenario we want to cover and whether they're done.

    @khiminrm: Were the bugs you fixed as part of #74 things related to the revisions change or existing functionality in Commerce?

  • 🇺🇸United States DamienMcKenna NH, USA

    Also, should this go into 3.0.x instead of 8.x-2.x?

  • 🇺🇸United States DamienMcKenna NH, USA

    FYI patch #74 still applies, but there was a little fuzz on one file so here's a clean reroll.

  • 🇮🇱Israel jsacksick

    This was initially targeting 3.x, not really sure why I changed it back to 2.x...

    My main concern with revisions is the inability to disable them... On a large project I'm working on, enabling revisions would cause the DB to grow way too quickly...

    Also, there's still a data loss concern... Which makes me wonder if we shouldn't instead introduce a commerce_product_revision module, which swaps the Product entity class to one that supports revisions... But... That maybe unrelastic as there's code elsewhere that still wouldn't require changes to account for revisions...

  • 🇺🇸United States DamienMcKenna NH, USA

    Moving to v3.

    My main concern with revisions is the inability to disable them... On a large project I'm working on, enabling revisions would cause the DB to grow way too quickly...

    Following node's workflow, it's not assumed that a change on the node would result in a new revision, that default is controllable per content type. So why would this be any different?

  • 🇮🇱Israel jsacksick

    Well, what I meant (sorry if I was unclear) is that even if you're not planning to use revisions, the data model is still affected regardless.

    Which means, duplicate revision tables for fields, for the main table as well (i.e commerce_product_revision). That surely has a non neglible impact on performance.

    I wouldn't like having to suddenly worry about this on the relatively large sites I'm currently maintaining.

    The content type setting doesn't have any impact on any of that. (it just drives whether a new revision is created on save).

  • 🇺🇸United States DamienMcKenna NH, USA

    Ok, ISWYM.

  • 🇺🇦Ukraine tbkot

    #74 works for me. One thing that I would like to add is the relationship of the view between revision and the actual entity. It was not covered by CommerceEntityViewsData so I've added some changes for it to work the same as it was done in the EntityViewsData.
    Interdiff is not working, changes were added at the end of the patch.

  • 🇩🇪Germany Anybody Porta Westfalica

    @jsacksick Re #84 wouldn't that mean that Drupal already has a by far larger issue with performance and revisions, as it uses nodes and they are revisionable?

    What I read here is:

    We're afraid of the revisions database structure, that is used for nodes ever since?

    Do I get that right?

    Wouldn't then any large project, using nodes, make a wrong pick with Drupal?

    Just playing Devils Advocate ;) To clarify things.

  • 🇬🇧United Kingdom c_archer Cumbria

    Currently using a patch in #87 which does work but the time stamp and author is always the same.

  • 🇺🇦Ukraine tbkot

    Based on the node behavior, this patch below adds a moderation handler to the product entity.

  • 🇬🇧United Kingdom c_archer Cumbria

    Patch on #60 currently fails against latest commerce release 2.37.0

  • Pipeline finished with Failed
    8 months ago
    Total: 432s
    #135292
  • Pipeline finished with Failed
    8 months ago
    Total: 429s
    #135334
  • Pipeline finished with Failed
    8 months ago
    Total: 427s
    #135349
  • Pipeline finished with Skipped
    8 months ago
    #136555
  • Pipeline finished with Failed
    8 months ago
    Total: 509s
    #137465
  • Status changed to Needs review 8 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 8 months ago
    Patch Failed to Apply
  • 🇺🇦Ukraine andriy khomych

    I've tested locally. I think we can move it to "Needs review".

  • Pipeline finished with Failed
    7 months ago
    Total: 513s
    #147218
  • Pipeline finished with Success
    7 months ago
    Total: 426s
    #147229
  • 🇺🇦Ukraine tbkot

    Patch with the latest changes from MR

  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 6 months ago
    Not currently mergeable.
  • Pipeline finished with Canceled
    6 months ago
    Total: 15s
    #187530
  • Pipeline finished with Canceled
    6 months ago
    Total: 183s
    #187527
  • Pipeline finished with Success
    6 months ago
    Total: 540s
    #187531
  • Pipeline finished with Failed
    6 months ago
    Total: 428s
    #187552
  • 🇩🇪Germany Anybody Porta Westfalica

    The fork needs to be updated and conflicts needs to be resolved. Anyway, this looks quite far implemented. Thank you @tBKoT for pushing things forward.
    Implement a generic revision UI Fixed and 🐛 Revert and Delete actions should not be available for the current revision Fixed are both resolved in core. So this should be compared to what https://www.drupal.org/node/3160443 suggests.

    Maybe "Needs tests" tag can be removed, I can see the Mr has tests.

    I think there are quite a few projects where it would be great to have revisions for products and product variations to be able to track changes and revert them if needed!

  • 🇩🇪Germany Anybody Porta Westfalica

    Made the title reflect the implementation.

  • First commit to issue fork.
  • 🇩🇪Germany Grevil

    Rebased it. Let's see what the tests say.

  • Pipeline finished with Failed
    4 months ago
    Total: 518s
    #241787
  • Status changed to Needs work 4 months ago
  • 🇩🇪Germany Grevil

    Ok, seems like this some test inside "ProductLayoutBuilderIntegrationTest" fails for the next major drupal release.

    Back to needs work.

  • Pipeline finished with Success
    3 months ago
    Total: 393s
    #254987
  • Status changed to Needs review 3 months ago
  • 🇩🇪Germany Grevil

    Tests succeed again, after rebasing on current 3.0.x-dev!

  • Status changed to Needs work 3 months ago
  • 🇩🇪Germany Grevil

    This issue just came up in Slack again: https://drupal.slack.com/archives/C1TLCCF9B/p1724339226822049

    There is still no final decision, whether this issue will ever see the light of day, but it definitely won't be 3.0.x.

    The current state of this issue branch add revision support for both products and product variations. There were some discussions earlier inside this issue and slack, whether to only support revisioning products, but at least for our use case, we'd need revision support for both products and product variations.

    The current MR currently doesn't include the typical "Create new revision" checkbox used on most revisionable entities:

    Hence, I am setting this back to needs work.

    An even better approach mentioned by @jsacksick over @Slack would be to be able to opt in to revisioning when creating a product- / product-variation-type. This seems to be the way forward, if we want this feature getting merged in future 4.x / 5.x releases. But that's not straight forward, as this feature isn't currently supported by Drupal "out of the box" and (might) need a lot of work.

Production build 0.71.5 2024