Errors in server error files logs

Ask the community for help and support.
Post Reply
14Steve14
VIP Member
VIP Member
Posts: 549
Joined: Fri Oct 25, 2019 7:01 pm
Has thanked: 8 times
Been thanked: 49 times

Errors in server error files logs

Post by 14Steve14 »

Phoenix version 1.0.7.11

I hope this sort of makes sense.
[28-Apr-2021 06:36:28 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/####/public_html/includes/system/override/shopping_cart.php on line 154
[28-Apr-2021 06:36:28 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/####/public_html/includes/system/override/shopping_cart.php on line 172
I have the above warnings showing in my server error logs.

The file in question is a copy of the shopping cart file from the 1.0.7.3 folder in versioned but with some added code, which has been added to the override folder so the items in the shopping cart are sorted into model number. This was code given by Gary in the older forum and works as expected.

Here is the code that was added

Code: Select all

array_multisort(array_map(function($e) { return $e['model']; }, $products), SORT_ASC, $products);
    }
which was added above

Code: Select all

      return $products;
Is there any thing wrong with that code that would affect the following lines which are causing the errors
Line 154 is foreach (($attributes ?? []) as $option => $value) {

and line 172 is

foreach (($attributes ?? []) as $option => $value) {
The sort order is working as expected and apart from those two warnings everything else is working fine.

If I remove the shopping cart file in the override folder I cannot get the warnings to show.

Is this anything to worry about or is it ok leaving it.
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Errors in server error files logs

Post by ecartz »

14Steve14 wrote: Thu Apr 29, 2021 8:38 am

Code: Select all

array_multisort(array_map(function($e) { return $e['model']; }, $products), SORT_ASC, $products);
    }
That has an extra } in it. So if you added those two lines and only those two lines, stuff would break. You could write the first line more briefly as

Code: Select all

array_multisort(array_column($products, 'model'), SORT_ASC, $products);
Since you're not reporting the problem that I would expect from that, I'm guessing that you either didn't add the } that you show or that you also made some other change.

I think that 1.0.7.11 may have had a bug that was fixed with https://github.com/CE-PhoenixCart/Phoen ... 757eb35146

That bug would cause the problem that you are seeing.
14Steve14
VIP Member
VIP Member
Posts: 549
Joined: Fri Oct 25, 2019 7:01 pm
Has thanked: 8 times
Been thanked: 49 times

Re: Errors in server error files logs

Post by 14Steve14 »

Cheers @ecartz. I have made the change and will see what happens now.

You say there is an extra } in it, but that is the code straight from what was in the original shopping cart file from that version as all I did was copy it and add the extra bit in before saving it to the override folder. I will take another look at the original that I have and change it if it is wrong. Thanks for the help as always.
Post Reply