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

[BUG] Product options null value returns 400 instead of 500 #12501

Merged
merged 3 commits into from Apr 1, 2021

Conversation

SirDomin
Copy link
Contributor

@SirDomin SirDomin commented Apr 1, 2021

Q A
Branch? 1.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets
License MIT

@SirDomin SirDomin requested a review from a team as a code owner April 1, 2021 06:01
@SirDomin SirDomin added API APIs related issues and PRs. Bug Confirmed bugs or bugfixes. labels Apr 1, 2021
@SirDomin SirDomin changed the title [BUG] Product options null value [BUG] Product options null value returns 400 instead of 500 Apr 1, 2021
src/Sylius/Component/Product/Model/ProductVariant.php Outdated Show resolved Hide resolved
@@ -45,7 +45,7 @@ public function addOptionValue(ProductOptionValueInterface $optionValue): void;

public function removeOptionValue(ProductOptionValueInterface $optionValue): void;

public function hasOptionValue(ProductOptionValueInterface $optionValue): bool;
public function hasOptionValue(?ProductOptionValueInterface $optionValue): bool;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this change is not a BC Break, although it expands the accepted argument, wdyt @lchrusciel

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 That's a BC break, all classes implementing this interface have to change their method signature.

{
return $this->optionValues->contains($optionValue);
return $optionValue === null ? true : $this->optionValues->contains($optionValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why true instead of false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is abit tricky, because by returning true we force it ProductVariant to dont allow null as argument and handle it as bad request.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is tricky because it feels wrong to check whether a product variant has an option value null. I think we should fix it upstream and do not let null to be passed to this method in the first place.

@lchrusciel lchrusciel merged commit f2e95c0 into Sylius:1.8 Apr 1, 2021
@lchrusciel
Copy link
Member

Thank you, @SirDomin! 🥇

pamil added a commit that referenced this pull request Apr 9, 2021
This PR was merged into the 1.8 branch.

Discussion
----------

Introduced in #12501.

Commits
-------

67bf126 Revert BC break in ProductVariantInterface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API APIs related issues and PRs. Bug Confirmed bugs or bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants