Skip to content

When canceling order with OrderService, the cancel method always saves the order and returns true, even if the order can not be canceled. #10803

@ekuusela

Description

@ekuusela

I'm assuming the cancel method in OrderService is supposed to return true only if the cancellation was a success.

But, since the cancel method in Order always returns the order itself, the service method ends up always saving and returning true as if the order was cancelled.

public function cancel()

This is confusing if not broken. The meaning of the boolean return value should be documented and if it is indeed meant as an indicator of successful cancelation, the service method should be fixed.

I'll include the boilerplate below to prevent this issue from getting auto-marked as not helpful.

Preconditions

  1. Fresh Magento 2 version (see links to functions in develop branch above)

Steps to reproduce

  1. Look at phpdoc in OrderService's cancel method and try to understand it's return value.

Expected result

  1. A clear understanding of the return value AND
  2. Return value corresponding to reality, for example, true only if order was canceled.

Actual result

  1. Confusion. Looks like the return value might indicate cancelation success, but it does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for development

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions