Jump to content

PHP Warning: Invalid argument supplied for foreach()


Recommended Posts

I've moved to new server and suddenly after getting order i have PHP Warning in logs:

 

[Sun Oct 20 13:00:59 2013] [error] [client 78.9.5.23] PHP Warning: Invalid argument supplied for foreach() in /home/myaccount/domains/mydomain.de/public_html/classes/Product.php on line 2800, referer: http://www.mydomain.de/modules/cashondelivery/validation.php

line 2800 of product.php is:
 

foreach ($products AS &$productUpdate)

what could be the reason ? i've never seen such a warning on my old server

 

Link to comment
Share on other sites

it looks like the $products variable is empty, and you should have there an array with $products

are you able to verify it? just put somewhere in php print_r($products) (make sure that this variable exists first) or in .tpl {$products|print_r}

Link to comment
Share on other sites

  • 1 year later...

Hello,

 

Please help, we've been getting this error for the past week. "PrestaShop Fatal error: no utf-8 support. Please check your server configuration." It occurs around 7 times a day. Resetting the database user fixes it for a while.

 

Our hosting response (ipage): You are experiencing this issue because your database user 'xyzuser' has exceeded the query limit set in our server which is 75000/hour.

 

We told Ipage that we've been operating flawlessly for 3 years. In past months traffic and orders have decreased. Therefore any increase in queries seems illogical. In addition we monitored the SQL process list ID and hourly intervals resulted in less than 45000/hr queries.

 

Error seems to be triggered while we are filling an order in the front office. Some orders are generated without any problem and others seem to trigger the error.

 

The first time the error occurred the cgi_error_log recorded the following error:

 

20150811T083347: xyzwebsite.com/shop/order.php

PHP Warning:  Invalid argument supplied for foreach() in xyzlocalserver/shop/classes/Cart.php on line 375

PHP Warning:  Invalid argument supplied for foreach() in xyzlocalserver/shop/classes/Cart.php on line 375

PHP Warning:  Invalid argument supplied for foreach() in xyzlocalserver/shop/classes/Cart.php on line 375

PHP Warning:  Invalid argument supplied for foreach() in xyzlocalserver/sh  (error abruptly ends here)

 

We can't tell if this error trigger the database error or the other way around

 

SQL runtime information shows the database restarted the night before the whole problem began. "This MySQL server has been running for 8 days, 18 hours, 27 minutes and 29 seconds. It started up on Aug 10, 2015 at 10:55 PM.

 

Ipage offered to increase query limit to 150000/hr, but all evidence shows we are not exceeding the 75000 limit. Even with the evidence it looks like that is our last resource.

 

Do you have any insight?

 

Prestashop version: 1.4.6.2

MySQL - 5.5.44-0ubuntu0.12.04.1-log

phpMyAdmin - 2.8.0.1

Link to comment
Share on other sites

PrestaShop is quite database demanding. Go for unlimited queries. I personally don't like this kind of hosting limitations as it may cause unpredictable problems.

 

Hello tuk66, thank you very much for the reply. Yesterday I requested ipage to increase from 75,000 to 150,000 queries/hr. Today we thought the problem had been fixed but the error appeared again 25 hrs after the increase to 150,000. In he past 7 days the error occured 5-6 daily. It seems like an improvement. We have been with ipage for 3+ years and have handled greater traffic & orders without problems. Currently we are processing only about 25 orders/day.

 

We've been monitoring queries on phpMyAdmin>Show processes....If process ID = 1 query, then:

@8:00am ID counter = 9545693

@12:30pm ID counter = 9723637 (when the error appeared)

Total Queries in 4.5 hours 177,944, this is far below the 150,000/hr queries allowed.

 

I keep thinking the issue may be related to something else, or Ipage is not telling us the truth about the limits in queries. Ipage says there is no way to see this query limit or monitor queries/hr from the Control Panel, only from their back end.

 

What do you think?

Link to comment
Share on other sites

Hello tuk66, 

 

I have monitored manually every hour in the past week, I decided to monitor every 30min this time. I don't know how to monitor it by cron, but I did it manually by looking at the SQL process list ID every hour.

 

You can see that at not interval we go over the 150,000/hr query limit. But since we upgraded from 75,000 to 150,000 queries per hour the errors have been reduced from 8 a day to 1 a day (aprox). Either I am monitoring the wrong value, or Ipage is not telling the whole truth.

 

August 24th Monitoring

 

Time / SQL Process ID / Queries per 1/2 hr

8:00 12280765  

8:30 12303988          23223

9:00 12329732          25744

9:30 12358272          28540

10:00 12387234        28962

10:30 12431770        44536

11:00 12448450        16680

11:30 12477524        29074

12:00 12510061        32537

12:17       ERROR   

12:30 12524655        14594

13:00 12533879         9224

13:30 12556772        22893

14:00 12577498        20726

14:30 12599768        22270

15:00 12622735        22967

15:30 12673403        50668

Edited by comprausa (see edit history)
Link to comment
Share on other sites

Hello tuk66,

 

Why would ipage numbers differ from mine by 3 times as much?

 

If I increase the limit further I am ignoring the fact that we have had a lot more traffic and orders (queries) in the past with no ocurrence of this issue. Shouldn't I be looking for true the cause of the error?

 

Thanks again.

Link to comment
Share on other sites

  • 1 year later...

Hello I have this error, any can solution this problem????

 

[PrestaShopException]

No access reference in table module_access for id_module 74.
at line 2538 in file classes/module/Module.php

2533.                 self::$cache_permissions[$employee->id_profile][$row['id_module']]['uninstall'] = $row['uninstall'];2534.             }2535.         }2536. 2537.         if (!isset(self::$cache_permissions[$employee->id_profile][$id_module])) {2538.             throw new PrestaShopException('No access reference in table module_access for id_module '.$id_module.'.');2539.         }2540. 2541.         return (bool)self::$cache_permissions[$employee->id_profile][$id_module][$variable];2542.     }2543. 
Link to comment
Share on other sites

Hello I have this error, any can solution this problem????

 

[PrestaShopException]

No access reference in table module_access for id_module 74.
at line 2538 in file classes/module/Module.php

2533.                 self::$cache_permissions[$employee->id_profile][$row['id_module']]['uninstall'] = $row['uninstall'];2534.             }2535.         }2536. 2537.         if (!isset(self::$cache_permissions[$employee->id_profile][$id_module])) {2538.             throw new PrestaShopException('No access reference in table module_access for id_module '.$id_module.'.');2539.         }2540. 2541.         return (bool)self::$cache_permissions[$employee->id_profile][$id_module][$variable];2542.     }2543. 
Link to comment
Share on other sites

×
×
  • Create New...