-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Product custom options always selected to "Yes" in PHP8.1 #2440
Comments
Hi and thanks for the report, I've created #2441 to fix the problem, it's a slightly different implementation (to be more consistent with the past codebase) but it should work. |
I take a look at the js: magento-lts/app/design/adminhtml/default/default/template/catalog/product/edit/options/option.phtml Lines 75 to 80 in cc051f2
My analysis: OT, to step through the js in Firefox, I needed to add But it is a good idea to have a proper check on line 76. |
@kiatng @fballiano Hi, thanks for your fast testing and your reply. I've two enviroments, one with PHP7 and one with PHP8.1 and in PHP7 I get "0" and in PHP8.1 i get INT 0 for "is_requiere" which caused lots of problems with my products. Maybe some PHP settings causes different behaviour in JSON enconding ?!? But, its truly fair to check by an proper way. Thanks at all. |
mmm i'm not sure why but on my php8.1 environment I could reproduce the problem immediately. |
The "problem" (or behavior change) lies deeper than JSON encoding. In PHP 8.1 all integers from database/PDO so e.g. IDs are no longer strings but integers. This is then handed down and results in this case in "is_required" as an int. I didn't do a deep dive yet, at which point in the code this change happens specifically though (is it already changed in built-in PHP or does the change occur in OpenMage implementation regarding database). |
The custom options are always selected to yes, even if "No" is selected. The reason is the since PHP 8.1 the JSON data.is_requiere is 0 instead of "0" and the code below isn't processed any more, because the condition is false.
magento-lts/app/design/adminhtml/default/default/template/catalog/product/edit/options/option.phtml
Line 76 in cc051f2
The line just needs to be changed to
if (data.is_require != undefined) {
The text was updated successfully, but these errors were encountered: