In laravel how do you solve "foreach argument must be of type array|object, null given"?

In laravel how do you solve "foreach argument must be of type array|object, null given"?

koniahinkoniahin Posts: 186Questions: 39Answers: 7

The error upon saving/updating a form is:

foreach argument must be of type array|object, null given

When it occurs you X out to close the popup editor and click either the Edit button (above) or inline edit link in each row. No need to reload the form page.

This is an inconsistent problem. With my older php websites it never happened. Since transitioning to laravel we see it. A little background. When the hosting server had 75GB diskspace and 4GB RAM it would happen several times per week, say gusssingly once in 25-50 posts. There are probably 50+ DTE forms on our sites, various flavors. Some use CKEditors others no. The error does not seem to be CKEditor-related, just making the note.

Since upgrading the server to 100GB and 6GB RAM it rarely occurs, twice in one month. Maybe under .5% I don't know. The last time it occurred was with one of our tiny, really basic forms. I'm speculating that the RAM helped.

Due to the unpredictability it is difficult to troubleshoot. I am not javascript-skilled, do occasionally use web developer in Firefox but aside from the Console basics am not much familiar with all the options/tabs. I would need to be guided in advance - and when it occurs get the information you need.

If you need access to the devel site I can probably arrange that. The pictures attached I grabbed the last time it occurred from the Console of web developer.

Thx

Answers

  • koniahinkoniahin Posts: 186Questions: 39Answers: 7

    To assist in troubleshooting I sent Allan access information to the development website. I've observer that the foreach error is now occurring at its normal pace. Those 3 weeks of bliss must have been a mirage.

    The site has many more forms than what you see. The error, however, does not discriminate. It can randomly happen to any form, does not appear to be related to server resources or current load, etc.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    Thanks for the details. I've e-mailed back a few questions :)

    Allan

Sign In or Register to comment.