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

[PW-5810] Enforce correct states when multiple states are assigned to a status #1397

Merged
merged 9 commits into from Mar 28, 2022

Conversation

tnaber
Copy link
Contributor

@tnaber tnaber commented Mar 16, 2022

Description
This PR addresses the issue from #1173.
When configuring statuses, a status can be assigned to multiple states.
E.g. the status 'Waiting for capture' can be assigned to both the 'pending_payment' and 'processing' state. When configuring "Order status: payment authorisation" it is possible to select statuses that lead to the 'processing' state, thus 'Waiting for capture' is shown in the dropdown. When this status is selected it is possible for the flow to enter the 'pending_payment' state. This should not be possible.

Further explanation of the problem and the corresponding code can be found in #1173. This PR proposes a solution in which the possible states are passed as a parameter when the setState function is called in the Webhook module. Before selecting a state to enter, the list of possible states will be filtered on this parameter.
E.g. this will prevent the 'pending_payment' state from the example to be removed.

When multiple states are possible to enter, and the passed status is also tied to all of these states (e.g. if 'Waiting for capture' would be assigned to both 'new' and 'processing' on "Order status: payment authorisation"). The first one that fits will be selected. This means the unpredictability is not fully removed, however this should be clear to the user as the 'Waiting for capture' label will appear multiple times in the dropdown.

Tested scenarios

  • Tested for multiple states

Fixed issue:
Fixes #1173

@tnaber tnaber changed the title Helper/Webhook.php [PW-5810] Enforce configured states after multi-state status selection Mar 16, 2022
@tnaber tnaber marked this pull request as ready for review March 16, 2022 14:10
@tnaber tnaber changed the title [PW-5810] Enforce configured states after multi-state status selection [PW-5810] Enforce correct states when multiple states are assigned to a status Mar 16, 2022
Helper/Webhook.php Outdated Show resolved Hide resolved
@tnaber tnaber requested a review from acampos1916 March 17, 2022 09:46
@sonarcloud
Copy link

sonarcloud bot commented Mar 28, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@tnaber tnaber merged commit 27372aa into develop Mar 28, 2022
@Morerice Morerice mentioned this pull request Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PW-5810] Unpredictable order state change
3 participants