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

Fixed SQL apostrophe (') incompatibility #34441

Merged
merged 3 commits into from Nov 2, 2023
Merged

Conversation

Lunyyx
Copy link
Contributor

@Lunyyx Lunyyx commented Nov 1, 2023

Questions Answers
Branch? 8.1.x
Description? Fixed the problem that was caused by apostrophes in SQL queries, this problem happened when the user write something like "Merci d'insérer votre personnalisation" as the apostrophe (') was considered as the end of the string.
Type? bug fix
Category? BO
BC breaks? no
Deprecations? no
How to test? Try to duplicate an item with a apostrophe (') in the customization field
Fixed issue or discussion? Fixes #34442

@Lunyyx Lunyyx requested a review from a team as a code owner November 1, 2023 20:25
@prestonBot
Copy link
Collaborator

Hello @Lunyyx!

This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community!

@prestonBot
Copy link
Collaborator

Hi, thanks for this contribution!

I found some issues with the Pull Request description:

  • Your pull request does not seem to fix any issue, consider creating one (see note below) and linking it by writing Fixes #1234.

Would you mind having a look at it? This will help us understand how interesting your contribution is, thank you very much!

About linked issues

Please consider opening an issue before submitting a Pull Request:

  • If it's a bug fix, it helps maintainers verify that the bug is effectively due to a defect in the code, and that it hasn't been fixed already.
  • It can help trigger a discussion about the best implementation path before a single line of code is written.
  • It may lead the Core Product team to mark that issue as a priority, further attracting the maintainers' attention.

(Note: this is an automated message, but answering it will reach a real human)

@prestonBot prestonBot added 8.1.x Branch Bug fix Type: Bug fix labels Nov 1, 2023
@Lunyyx
Copy link
Contributor Author

Lunyyx commented Nov 1, 2023

Hi, thanks for this contribution!

I found some issues with the Pull Request description:

  • Your pull request does not seem to fix any issue, consider creating one (see note below) and linking it by writing Fixes #1234.

Would you mind having a look at it? This will help us understand how interesting your contribution is, thank you very much!

About linked issues

Please consider opening an issue before submitting a Pull Request:

  • If it's a bug fix, it helps maintainers verify that the bug is effectively due to a defect in the code, and that it hasn't been fixed already.
  • It can help trigger a discussion about the best implementation path before a single line of code is written.
  • It may lead the Core Product team to mark that issue as a priority, further attracting the maintainers' attention.

(Note: this is an automated message, but answering it will reach a real human)

Fixed the old pull request

Fixed the code according to the PHP CS Fixer
Co-authored-by: Daniel Hlaváček <daniel.hlavacek@hotmail.cz>
Copy link
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

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

I think it's OK. :-)

Some prepared statement or built in escape method would probably be better, but given the scope of that method and how it manually builds the query by joining the fields, it should work just fine. There should be no other possible fails that it could encounter, the rest of the query is not dynamic.

@M0rgan01 M0rgan01 added this to the 8.1.3 milestone Nov 2, 2023
@M0rgan01
Copy link
Contributor

M0rgan01 commented Nov 2, 2023

@Hlavtox
Copy link
Contributor

Hlavtox commented Nov 2, 2023

@M0rgan01 I think you ran the tests on develop instead of 8.1.x ;-)

@Lunyyx
Copy link
Contributor Author

Lunyyx commented Nov 2, 2023

I think it's OK. :-)

Some prepared statement or built in escape method would probably be better, but given the scope of that method and how it manually builds the query by joining the fields, it should work just fine. There should be no other possible fails that it could encounter, the rest of the query is not dynamic.

Perfect ! :)

Yes, I think it's weird that there isn't any buildt in functions to do this, but anyway, it should work without any problem yes

@ps-jarvis ps-jarvis added the Waiting for QA Status: action required, waiting for test feedback label Nov 2, 2023
@florine2623 florine2623 self-assigned this Nov 2, 2023
Copy link
Contributor

@florine2623 florine2623 left a comment

Choose a reason for hiding this comment

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

Hello @Lunyyx ,

The field is not duplicated anymore. The process to checkout is working as expected.

It is QA ✅
Thanks!

@florine2623 florine2623 added QA ✔️ Status: check done, code approved and removed Waiting for QA Status: action required, waiting for test feedback labels Nov 2, 2023
@Hlavtox
Copy link
Contributor

Hlavtox commented Nov 2, 2023

@florine2623 I'm not sure I understand the message. :-)

This issue was about an error when duplicating a product in BO.
It didn't work before, now it should work with this PR.

Copy link
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

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

Block to avoid accidental merge

@Lunyyx
Copy link
Contributor Author

Lunyyx commented Nov 2, 2023

@florine2623 I'm not sure I understand the message. :-)

This issue was about an error when duplicating a product in BO. It didn't work before, now it should work with this PR.

Yes it is, maybe I didn't explained correctly, it's just about duplication of products in the BO as you said.
Do I need to do something, or I just need to wait for someone to accept it ?

@ps-jarvis ps-jarvis added the Waiting for QA Status: action required, waiting for test feedback label Nov 2, 2023
@matthieu-rolland
Copy link
Contributor

why shouldn't the PR be merged @Hlavtox ?

@florine2623
Copy link
Contributor

florine2623 commented Nov 2, 2023

Hello @Hlavtox ,

The field was duplicated here in FO :
Screenshot 2023-11-02 at 15 17 07

And with the PR, the problem does not show up anymore ^^

Screenshot 2023-11-02 at 15 18 51

For me it is OK to be merged

@Hlavtox
Copy link
Contributor

Hlavtox commented Nov 2, 2023

@florine2623 OK, but the problem was in the backoffice, as you can see on video from @paulnoelcholot here - #34442 (comment)

Snímek obrazovky 2023-11-02 152831

@florine2623
Copy link
Contributor

Hello again @Hlavtox and @Lunyyx ,

Indeed, well it seems that 2 problems are fixed then !
No duplication in FO and no error while duplicating a product in BO, when using an apostrophe ✅

Although, now, I have a deprecation alert in FO whenever I duplicate a product. Whether there's an apostrophe or not :
Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /my_shop/classes/Validate.php on line 683

Screenshot 2023-11-02 at 15 36 23

Could you check ?

@florine2623 florine2623 added Waiting for author Status: action required, waiting for author feedback and removed Waiting for QA Status: action required, waiting for test feedback QA ✔️ Status: check done, code approved labels Nov 2, 2023
@kpodemski
Copy link
Contributor

@florine2623 is it really because of this PR? did you check it on installation without it?

@florine2623
Copy link
Contributor

Hi again ^^

This PR can be merged as seen with @Hlavtox .
The other problem that I have is related to #33492 and can be fixed later on !

@florine2623 florine2623 added QA ✔️ Status: check done, code approved and removed Waiting for author Status: action required, waiting for author feedback labels Nov 2, 2023
@Hlavtox
Copy link
Contributor

Hlavtox commented Nov 2, 2023

We checked with florine privately and the issue is not related. So all good. :) Thanks everyone!

@Hlavtox Hlavtox merged commit 31b0f48 into PrestaShop:8.1.x Nov 2, 2023
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.1.x Branch Bug fix Type: Bug fix QA ✔️ Status: check done, code approved
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

8 participants