Undo temporary workaround on order item/order save process

Created on 7 February 2025, 2 months ago

Problem/Motivation

In #3017259: branch tests are failing β†’ an explicit save of an order item is performed prior to adding the item to an order. This was in 2019 to work around some strangeness with Entity API, but it results in a condition where the order is saved _during_ the save of the order item (due to the entity reference field containing a link _to_ said order). This can lead to WTF conditions if you have, say, a hook responding to order insertion and want to introspect its items to do some business logic.

I suspect this can be removed, now.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

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

Merge Requests

Comments & Activities

  • Issue created by @bradjones1
  • Merge request !41Try removing order item early save β†’ (Open) created by bradjones1
  • Pipeline finished with Failed
    2 months ago
    Total: 218s
    #418050
  • Pipeline finished with Failed
    2 months ago
    Total: 226s
    #418226
  • Pipeline finished with Success
    2 months ago
    Total: 220s
    #418241
  • πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

    I need to check out for the weekend but I think this sums up well the underlying issue of an unsaved order item being saved during order save.

    It might be that this is in fact just unsupported in commerce. If that's so, we should detect this condition early and throw an exception, because otherwise this 1) requires developers to magically know they can't rely on functionality that otherwise "just works" in Entity API without breaking those contracts and 2) results in broken order data (namely, the total) in a rather undeterministic manner.

    This is covered in πŸ“Œ Saving an order with unsaved order items results in tough-to-debug data inconsistency Active so I'll put more discussion there. For recurring, the question is whether we accept this bug is really in Commerce Order and work around it here? Probably. That would mean keeping the workaround in place, updating it with a reference here, and then acting accordingly in the recurring ecosystem.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 219s
    #426141
  • Pipeline finished with Failed
    about 2 months ago
    Total: 258s
    #426147
  • πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

    Test coverage was incorrect to begin with, I think... and this is postponed on πŸ“Œ Saving an order with unsaved order items results in tough-to-debug data inconsistency Active in Commerce core which allows us to back out the work-around in recurring.

Production build 0.71.5 2024