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
Validate smarty render calls (prevent errors from outdated themes) #34448
Validate smarty render calls (prevent errors from outdated themes) #34448
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the type of $ui
should be checked before calling its method (phpstan error)
9d7af17
to
153d881
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should have incorrect theme
What is "incorrect" 😉 ?
@matks You can simulate this by putting |
I saw this problem about 4 times for last month in production PS eshops with theme oficially targeted for PS 8.1, but in reality, with this problem like hlavtox already wrote... :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @ShaiMagal ,
I do not have the same Notices as you. Only the last one is the same.
Warning: Undefined array key "register_form" in /Users/fHea/Desktop/pr-ps810/var/cache/dev/smarty/compile/classiclayouts_layout_full_width_tpl/c4/d1/e2/c4d1e2f3ba3a5749ec1fa732c5e036efcb8985ce_2.file.order-confirmation.tpl.php on line 98
Warning: Attempt to read property "value" on null in /Users/fHea/Desktop/pr-ps810/var/cache/dev/smarty/compile/classiclayouts_layout_full_width_tpl/c4/d1/e2/c4d1e2f3ba3a5749ec1fa732c5e036efcb8985ce_2.file.order-confirmation.tpl.php on line 98
Could you check those 2 please ? :)
Thanks!
@florine2623 This is the result you should get. :-) It's QA ok. 👍 |
Seen with @Hlavtox , The warnings are displayed because a bad variable was used on purpose ! It is QA ✅ |
Good job, thanks everyone! |
Description
Some "up to date" templates are targeted for PS 8.1, but throwing fatal errors. For example on order confirmation page due to guest conversion box, because some templates are using obsolete code from older versions PS... :/ (check code below)
This PR improving this behaviour. Because this take 2 hours of my life to investigate, what is happening there and for other people it can be useful. It is problem with theme developers, but PrestaShop must do the best to protect customers from bad themes as well. For end customer is very complicated to find, why they are receiving Fatal error 500 with guest order only and for any developers as well........
This PR can handle this problem and can protect eshop owners from outdated themes for example.
This is part of incorrect usage. This is reason for Fatal error 500 (line with "{render file=XXXX}".
Here is the part of code, what is incorrectly used and do error 500 with PS 8.1
https://github.com/PrestaShop/PrestaShop/blob/e7a1e3e7cd8be3bc7a023b3c03c3bdd51ea4f1dc/themes/classic/templates/checkout/order-confirmation.tpl#L95C10-L95C10
The fix
This PR verifies if proper VALID parameters were submitted with the call, and point the user to faulty template. In production mode, the call will be skipped. In dev mode, it throws a notice.
Follows the same logic as in #31092.