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

Update function getCustomerOrders to avoid error #28117

Merged
merged 1 commit into from Apr 7, 2022

Conversation

NicolasCador
Copy link
Contributor

@NicolasCador NicolasCador commented Apr 4, 2022

Questions Answers
Branch? develop
Description? When an order is missing in table ps_order_history due to a crash during order creation, and when customer wants to see his/her order history, today, it gives a "ContextErrorException : Trying to access array offset on value of type null", because $orderState becomes null and so $orderState['name'], $orderState['invoice'], $orderState['color'] can't exist. By using Null Coalescing Operator instead of Ternary Operator, we avoid the error.
Type? bug fix
Category? FO
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #27967
How to test? See below
Possible impacts? Only order history in customer account.

Description

Today, it gives a "ContextErrorException : Trying to access array offset on value of type null", if there was a crash during order creation, because $orderState becomes null and so $orderState['name'], $orderState['invoice'], $orderState['color'] can't exist.
By using Null Coalescing Operator instead of Ternary Operator, we avoid the error.

How to test

Make an order in FO using customer ZJA
Remove its SQL lines from table ps_order_history table
Then browse customer account ZJA, click on order history.
See error


This change is Reviewable

@NicolasCador NicolasCador requested a review from a team as a code owner April 4, 2022 06:24
@prestonBot
Copy link
Collaborator

Hello @NicolasCador!

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)

Copy link
Contributor

@matthieu-rolland matthieu-rolland left a comment

Choose a reason for hiding this comment

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

lgtm

@prestonBot prestonBot added the develop Branch label Apr 6, 2022
@matks matks added the Waiting for QA Status: action required, waiting for test feedback label Apr 6, 2022
@HanaRebaiQA HanaRebaiQA self-assigned this Apr 7, 2022
Copy link

@HanaRebaiQA HanaRebaiQA left a comment

Choose a reason for hiding this comment

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

Hello @NicolasCador

I checked this PR. The issue is fixed.
Here my tested cases :

  • Check the related issue : OK
  • Check with create order from FO : OK
  • Check with create order from BO : OK
  • Check with create order from FO and update status from BO : OK
  • Check with different php versions (php7.4 and php7.2) : OK
  • Check with different languages (RTL and no RTL) : OK
  • Check with multistore : OK

With php 7.4

PR28117.-.php7.4.mp4

With php 7.2

PR28117.-.php7.2.mp4

So, it's QA ✔️

Thanks!

@HanaRebaiQA HanaRebaiQA added QA ✔️ Status: check done, code approved and removed Waiting for QA Status: action required, waiting for test feedback labels Apr 7, 2022
@prestonBot
Copy link
Collaborator

QA approved, well done! Message to the maintainers: do not forget to milestone it before the merge.

@kpodemski kpodemski added this to the 1.7.8.6 milestone Apr 7, 2022
@kpodemski kpodemski merged commit 4967ac4 into PrestaShop:1.7.8.x Apr 7, 2022
@kpodemski
Copy link
Contributor

Thank you @NicolasCador @HanaRebaiQA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug fix Type: Bug fix develop Branch QA ✔️ Status: check done, code approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants