Proposing this change, as it causes the same problem as we had in #2807567: Checkout fails when Editor module enabled. on adding an item to a fresh cart. Of course, both problems indicate, that a more sophisticated solution will be needed in the long run to avoid problems with nested save() calls. But that may take longer and may even affect Drupal Core.

Nevertheless, it would make sense anyway to inlcude that in the order refresh process for several reasons:

  1. We will get rid of an additional save() call in the entity's postSave() function, which will trigger further events anyway, no matter if we find a solution against having the stale data.
  2. The order refresh process gets called and saves the entity anyway. It already does a couple of things, like applying adjustments, setting order item titles, why not setting missing order numbers too?
  3. If moving the call after calling the refresh processors, we get an easy possiblility to set order numbers different to the id within a custom order refresh processor - that sounds great to me.

I'll propose a patch asap

Comments

agoradesign created an issue. See original summary.

agoradesign’s picture

Status: Active » Closed (won't fix)
Related issues: +#2820034: The order refresh can cause a save-within-a-save in certain circumstances

As discussed with bojanz, this could cause problems with offsite payments. And in my case it would only be a workaround for a different bug: adding #2820034: The order refresh can cause a save-within-a-save in certain circumstances as related issue and closing this one