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

[ApiBundle] Added remaining APIs for the Promotion resource. #15524

Merged

Conversation

Wojdylak
Copy link
Member

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

@Wojdylak Wojdylak requested a review from a team as a code owner November 13, 2023 14:39
@probot-autolabeler probot-autolabeler bot added the API APIs related issues and PRs. label Nov 13, 2023
Copy link

github-actions bot commented Nov 13, 2023

Bunnyshell Preview Environment deleted

Available commands:

  • /bns:deploy to redeploy the environment

@probot-autolabeler probot-autolabeler bot added the Maintenance CI configurations, READMEs, releases, etc. label Nov 13, 2023
@Wojdylak Wojdylak force-pushed the SYL-3164-api-cover-cart-promotion-management branch 2 times, most recently from a73d2df to 862b8a6 Compare November 13, 2023 15:21
Copy link

sonarcloud bot commented Nov 13, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

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

No Coverage information No Coverage information
0.6% 0.6% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@Wojdylak Wojdylak force-pushed the SYL-3164-api-cover-cart-promotion-management branch 6 times, most recently from b9b1b56 to f9bf245 Compare November 15, 2023 10:44
<group>admin:promotion:create</group>
<group>admin:promotion:update</group>
<denormalization_context>
<entry name="disable_type_enforcement">true</entry>
Copy link
Member

Choose a reason for hiding this comment

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

Why are you disabling it on the priority field?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the database, the priority column is not nullable, so serialization throws an error on null values. However, we want to allow sending null, because the setPriority method accepts null.

Copy link
Member

Choose a reason for hiding this comment

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

The question is whether we want to accept a null value if the db doesn't accept it. IMO allowing setting null is not a good choice.

Copy link
Member

Choose a reason for hiding this comment

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

IMO, if the database doesn't accept the null value, we shouldn't accept it during serialization

Copy link
Member Author

Choose a reason for hiding this comment

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

image
Setter allows setting a null value. If I set the value to null, it receives the last priority. If we remove the ability to set null, we would know what the last priority is.

Copy link
Member Author

Choose a reason for hiding this comment

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

#15551 I have removed possibility to set null value. We can achieve the same goal to pass a value of minus one.

@Wojdylak Wojdylak force-pushed the SYL-3164-api-cover-cart-promotion-management branch 2 times, most recently from 1cce2ff to 1c5fc26 Compare November 16, 2023 20:35
UPGRADE-1.13.md Outdated Show resolved Hide resolved
}

return $rules;
return empty($rules) ? [[]] : $rules;
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see that it's been like this before, but is there a particular reason why it's not a simple array?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, it has been working in a way that if I pass an empty array, then this normalizer returns an empty array within an array, which previously created a promotion with at least one action/rule. For the purpose of using this in Behat tests, where I need to create a promotion without any actions/rules, I've added the option to pass a null value. In this case, it will return an empty array, so no actions/rules are added. If someone passes an empty array, the behavior will remain as it was before.

@Wojdylak Wojdylak force-pushed the SYL-3164-api-cover-cart-promotion-management branch from 1c5fc26 to 2aecfb9 Compare November 19, 2023 18:20
@Wojdylak Wojdylak force-pushed the SYL-3164-api-cover-cart-promotion-management branch from 2aecfb9 to 70299c1 Compare November 20, 2023 10:37
phpstan-baseline.neon Show resolved Hide resolved
<group>admin:promotion:create</group>
<group>admin:promotion:update</group>
<denormalization_context>
<entry name="disable_type_enforcement">true</entry>
Copy link
Member

Choose a reason for hiding this comment

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

The question is whether we want to accept a null value if the db doesn't accept it. IMO allowing setting null is not a good choice.

<group>admin:promotion:create</group>
<group>admin:promotion:update</group>
<denormalization_context>
<entry name="disable_type_enforcement">true</entry>
Copy link
Member

Choose a reason for hiding this comment

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

IMO, if the database doesn't accept the null value, we shouldn't accept it during serialization

@GSadee GSadee merged commit d3ad385 into Sylius:1.13 Nov 22, 2023
25 checks passed
@GSadee
Copy link
Member

GSadee commented Nov 22, 2023

Thanks, Karol! 🥇

@Wojdylak Wojdylak deleted the SYL-3164-api-cover-cart-promotion-management branch November 30, 2023 07:58
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. Maintenance CI configurations, READMEs, releases, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants