Support Forum

Invalid argument after upgrading

FA Fabien
Fabien
Member

Hi,

After upgrading to WordPress 3.9 and Simple:Press 5.4.2 the following message is displayed at the top of the forum :

Warning: Invalid argument supplied for foreach() in /wp-content/plugins/simple-press/forum/content/classes/sp-list-topic-class.php on line 416

Can you please tell me how to remove it ?

Best Regards,

Fabien

10 Answers

New Answer

MP Mr Papa
Mr Papa
Member

have you had any new posts since the upgrade?  I suspect one new post will make it disappear but may need Andy to confirm…  this a new cache put in place and yours seems to not be primed…  obviously if thats the case we need to handle that situation but need some confirmation first…

YS Yellow Swordfish
Yellow Swordfish
Member

Actually this should not be an issue unless you have absolutely no posts in the forum at all. I have reworked the code so that it will no longer show up as a warning but the fact that you are seeing this is puzzling as if empty it should have been rebuilt.

I would be interested to know if this is seen on every page load and – if it does, indeed, go away when a new post is made.

Meanwhile I would really advise you against showing ANY errors like this. It discloses the path of the site to the casual observer and the recommended procedure is always to log these and not display them. I would personally be having very strong words with my host if this were my site!

FA Fabien
Fabien
Member

My forum is new and there was no post at all. After posting a new post, the error message disappeared. Thank you !

YS Yellow Swordfish
Yellow Swordfish
Member

That explains it. Thanks for the update. That code has been cleaned up so as not to necessarily expect posts! Appreciate the info.

FA Fabien
Fabien
Member

You’re right, I would not have had to write the entire path. Rookie mistake !

Can you please delete the path in my first message. ? I am not able to edit the message.

Thanks

YS Yellow Swordfish
Yellow Swordfish
Member

Done. But I was really meaning on your own site. Really bad form to show any errors on the public side… That includes notices and warnings.

BB Biz Buzz
Biz Buzz
Member

Hello, I hope I am not overstepping my bounds, but I got the very same error on my site, so I just chose to piggy back this post.

And yes, it is showing up so will have to discuss that with the host, however, let me tell you this.

I only installed 5.4.2 yesterday, and when I went in to start creating forums, this is the error that came up, exactly like posted above.

Thinking I would just have to submit a post and it would clear up, I came up with these errors:

Warning: array_unshift() expects parameter 1 to be array, string given in /wp-content/plugins/simple-press/sp-api/sp-api-class-post.php on line 457

Warning: Cannot modify header information – headers already sent by (output started at wp-content/plugins/simple-press/sp-api/sp-api-class-post.php:457) in /wp-includes/pluggable.php on line 1121

I had to back up, and refresh the page, and now it’s showing my topic and the error message is gone.

Any thoughts?

YS Yellow Swordfish
Yellow Swordfish
Member

Afraid it was caused by the same condition – no posts. At the time of writing the post there were still none in the database so it came up with the same warning. The headers already sent error was caused by the fact that the first real error (Warning) was printed to the display.

Apologies for it happening but once there is at least one post in the database all should then be well and these are fixed up in the next update…

BB Biz Buzz
Biz Buzz
Member

Since there is no “like” or “thanks” button, I am replying with a hearty THANKS!

YS Yellow Swordfish
Yellow Swordfish
Member

I think I should say thanks really. These are minor – non-destructive things… more annoyances really – but we do like to eradicate them when encountered so – thanks for finding them!