Page 1 of 1

(SOLVED) Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Thu Sep 29, 2022 10:48 am
by Cue4cheap
Ok I have a good one and here are the steps to reproduce:
Create an option name (aka category) - Lets say we create "Color" since there can be hundreds of colors
Edit said option name to add in the different options, Add in all the colors of the spectrum but create 249 of them! (or just add in numbers 1 - 249 to make it easy).
Save
Go back into that same option name and add in one more option.
Save
Go look in your error log.

Code: Select all

2022-09-28 2:58:11 - PHP Warning:  Undefined array key "option_value_description" in /home2/store/public_html/oc38/test/admin/controller/catalog/option.php on line 393
2022-09-28 2:58:11 - PHP Warning:  foreach() argument must be of type array|object, null given in /home2/store/public_html/oc38/test/admin/controller/catalog/option.php on line 393
2022-09-28 2:58:11 - PHP Warning:  Undefined array key "image" in /home2/store/public_html/oc38/test/admin/model/catalog/option.php on line 42
2022-09-28 2:58:11 - PHP Warning:  Undefined array key "sort_order" in /home2/store/public_html/oc38/test/admin/model/catalog/option.php on line 42
2022-09-28 2:58:11 - PHP Warning:  Undefined array key "option_value_description" in /home2/store/public_html/oc38/test/admin/model/catalog/option.php on line 49
2022-09-28 2:58:11 - PHP Warning:  foreach() argument must be of type array|object, null given in /home2/store/public_html/oc38/test/admin/model/catalog/option.php on line 49
Go back into that option name (aka category) and you will see one of the "Option value names" is blank (most likely the last one you entered).

This was done with a fresh install of OC3.0.3.8 and on my live site of 2.3.0.2.
Granted I have one server I am able to use and I have not changed around my settings in .htaccess or php.ini to try and see if there are changes I can make but I do not see any errors anywhere reported except for opencart's logs.
Mike

Re: Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Thu Sep 29, 2022 7:01 pm
by ADD Creative
What do you have post_max_size, max_input_time and max_input_vars set to in your PHP settings? You won't see any other errors than the ones in your log if these were too small.

Re: Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Thu Sep 29, 2022 7:31 pm
by Cue4cheap
ADD Creative thank you for the reply.
They are:
post_max_size = 516M
max_input_time = 60
max_input_vars = 1000
Mike

Re: Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Thu Sep 29, 2022 7:50 pm
by paulfeakins
As above this is most likely a hosting limit rather than anything to do with OC.

Re: Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Thu Sep 29, 2022 8:04 pm
by ADD Creative
Every option value requires 4 input variables, option_value_id, name, image and sort_order. If you have max_input_vars set to 1000 that will allow 249 values ((1000 - 3) / 4 = 249.25).

Re: Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Thu Sep 29, 2022 8:36 pm
by Cue4cheap
ADD Creative wrote:
Thu Sep 29, 2022 8:04 pm
Every option value requires 4 input variables, option_value_id, name, image and sort_order. If you have max_input_vars set to 1000 that will allow 249 values ((1000 - 3) / 4 = 249.25).
Well how about that? That is awesome reply and knowledge.
Thank you and I hope this helps others as it took me a bit of trail and error to understand why all of a sudden this issue popped up. I'll change that setting later today and test again but the math makes 100% sense.

Thank you again,
Mike

Re: (SOLVED) Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Fri Sep 30, 2022 6:15 am
by Cue4cheap
That was it. I don't know how many people will run into this but glad it is solved.

Re: Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Fri Sep 30, 2022 6:48 pm
by paulfeakins
Cue4cheap wrote:
Thu Sep 29, 2022 8:36 pm
I'll change that setting later today
You might as well set it really high, I don't think there are major downsides.

Re: Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Fri Sep 30, 2022 9:30 pm
by ADD Creative
paulfeakins wrote:
Fri Sep 30, 2022 6:48 pm
You might as well set it really high, I don't think there are major downsides.
The downside would be that PHP would be more vulnerable to a kind of denial of service attack.
https://www.php.net/manual/en/info.conf ... input-vars

Re: (SOLVED) Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Sat Oct 01, 2022 1:35 pm
by xxvirusxx
Cue4cheap wrote:
Thu Sep 29, 2022 10:48 am
2022-09-28 2:58:11 - PHP Warning: foreach() argument must be of type array|object, null given in
Based on this warning, you have >= PHP 8.0

Re: (SOLVED) Bug to report or server, php.ini, etc settings? OC 3.0.3.8 AND 2.3.0.2.

Posted: Sun Oct 02, 2022 12:17 am
by Cue4cheap
xxvirusxx wrote:
Sat Oct 01, 2022 1:35 pm
Cue4cheap wrote:
Thu Sep 29, 2022 10:48 am
2022-09-28 2:58:11 - PHP Warning: foreach() argument must be of type array|object, null given in
Based on this warning, you have >= PHP 8.0
That is correct and the reason I installed the OC3.0.3.8 and updating to the maintenance branch. I am adapting all of my scripts from 2.3.0.2 over the next couple of months before I make the switch to be ready for PHP 8.1 and above.
Mike