Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Internal adjustsments cache not updated after saving new adjustments? #3283

Open
boboldehampsink opened this issue Sep 28, 2023 · 6 comments
Assignees
Labels
commerce4 Issues related to Commerce v4 🔎 status: investigating Trying to reproduce ℹ️ status: need more info When waiting for user to supply database or more information.

Comments

@boboldehampsink
Copy link
Contributor

What happened?

In the method \craft\commerce\elements\Order::_saveAdjustments, previous adjustments can be deleted. But if you run $this->getAdjustments() again after that, the deleted adjustments are still there? I think _saveAdjustments should update the adjustments with setAdjustments after it has done its part.

Craft CMS version

4

Craft Commerce version

4

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@boboldehampsink boboldehampsink added commerce4 Issues related to Commerce v4 bug labels Sep 28, 2023
@lukeholder
Copy link
Member

lukeholder commented Sep 30, 2023

I do not think this is the case.

In memory (contained within Order::_orderAdjustments and retrieved in _saveAdjustments()) the orders have the adjustments that will be saved - it does not contain adjustments that will be deleted. We are purely deleting the old adjustment records that are no longer saved to the order.

Let me know if I am missing something.

@lukeholder lukeholder self-assigned this Sep 30, 2023
@boboldehampsink
Copy link
Contributor Author

@lukeholder ok let me tell you where this is coming from. We have a LOT of exceptions of "No line item exists with the ID “...”" - so I'm guessing there is some sort of race condition somewhere? Any thoughts? Here is a full stacktrace: https://robuust-6t.sentry.io/share/issue/d0e80dab2b3d4655bff6e3ceeadd866c/

@lukeholder
Copy link
Member

@boboldehampsink I can't tell much from the stack trace apart from the error being triggered due to the line item referencing an ID that has been deleted.

Do you have any custom module code manipulating the order or line items?

@lukeholder lukeholder added ℹ️ status: need more info When waiting for user to supply database or more information. 🔎 status: investigating Trying to reproduce and removed bug labels Nov 20, 2023
@boboldehampsink
Copy link
Contributor Author

Hi @lukeholder, no there is no custom code manipulating the order or line items. Also, this happens on various projects with Commerce.

@boboldehampsink
Copy link
Contributor Author

@lukeholder still seeing this error alot over various projects. I'll try to make it reproducible

@boboldehampsink
Copy link
Contributor Author

boboldehampsink commented Mar 18, 2024

Could this be some sort of race condition? Imagine a front-end which updates the cart via an ajax request (by clicking a button on a product cart). What would happen if you click many different buttons rapidly? At least this is when I can reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commerce4 Issues related to Commerce v4 🔎 status: investigating Trying to reproduce ℹ️ status: need more info When waiting for user to supply database or more information.
Projects
None yet
Development

No branches or pull requests

2 participants