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

Throw exception when editing an order and the old order could not be cancelled. #1170

Merged
merged 1 commit into from
Sep 1, 2020
Merged

Throw exception when editing an order and the old order could not be cancelled. #1170

merged 1 commit into from
Sep 1, 2020

Conversation

woutersamaey
Copy link
Contributor

@woutersamaey woutersamaey commented Aug 27, 2020

Throw exception when editing an order and the old order could not be cancelled.

This is to avoid having 2 open orders.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

…cancelled.

This is to avoid having 2 open orders.
@github-actions github-actions bot added the Component: Adminhtml Relates to Mage_Adminhtml label Aug 27, 2020
@joshua-bn
Copy link
Contributor

How/why did this happen for you?

@woutersamaey
Copy link
Contributor Author

woutersamaey commented Aug 27, 2020

I have some custom code that alters the result of $order->canCancel() to false (using an event, 100% clean code)

When you edit an order, the original order is canceled and a new is created.
Magento does not check if the original order is in fact canceled or not. It just continues with the creation of the new order.
The original order remains as it was and you end up with 2 open orders (breaking reports, confusing customers, etc). This is a mistake and we should break the order edit process with an exception.

The original order MUST be canceled.

@colinmollenhour
Copy link
Member

Seems like MSMOrder->cancel() should throw an exception if it can't be canceled?

@woutersamaey
Copy link
Contributor Author

woutersamaey commented Aug 28, 2020

Yes, absolutely! But will everyone support this change?
It's been like this since forever in Magento...

@colinmollenhour
Copy link
Member

Yes, absolutely! But will everyone support this change?
It's been like this since forever in Magento...

You're right, probably not worth a BC break.

@woutersamaey
Copy link
Contributor Author

@colinmollenhour Just to be clear, I'm all for throwing the exception if $order->cancel() fails. But can't decide this on my own.

It's very strange Magento does not throw an exception and just leaves things as is.
Imagine having to write extra code just to double check everything after doing something. It's insane.

Also: Should we leave bad code in? Just because some developer did a shitty job many many years ago? I think not.

I actually had a client run into this issue and had to explain them the situation. They could not believe the stupidity of Magento...

If @Flyingmana and @sreichel can agree, I'd be happy to move the exception to the cancel() method. If BC breaks, I'm assuming that module would be shit too.

All depends on your aim: You want a better program or you want BC (even when it is shitty code)?

@colinmollenhour
Copy link
Member

Ok, let me rephrase.. Probably not worth putting your fix on hold. So I think we can accept this as-is, and address the issue of cancel() not throwing an exception as a separate issue in a separate version. Although we really need to finalize the way we manage branches with BC changes in order to do that...

@woutersamaey
Copy link
Contributor Author

Sounds good. Let’s get this merged.

@kkrieger85 kkrieger85 merged commit a985746 into OpenMage:1.9.4.x Sep 1, 2020
@sreichel sreichel added this to the Release 19.4.7 / 20.0.3 milestone Sep 1, 2020
speedupmate pushed a commit to speedupmate/magento-lts that referenced this pull request Sep 16, 2020
aldrahastur pushed a commit to aldrahastur/magento-lts that referenced this pull request Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants