Archived topic
Warning: Invalid argument error
8 replies · Started by Kat on September 14, 2015
Hello
Hope you may be able to advise what this error message means - this has appeared on the home page after moving the website from the test directory to the public_html folder:
Warning: Invalid argument supplied for foreach() in /home/diamondp/public_html/wp-content/plugins/gp-premium/addons/generate-sections/functions/generate-sections.php on line 151
Thanks
Kitka
Hi there,
What version of GP Premium are you using?
How did you migrate the site to the new directory? I suggest giving the Duplicator plugin a try - it moves everything over seamlessly and should stop weird errors like this from happening.
Let me know :)
Thanks. The GP version is Version: 1.3.13
I placed a copy of all WordPress files in the public_html folder, copied the wp-content folder over and made a copy of the database but did a find-and-replace to edit out the path to the test directory. I have moved dozens of WordPress sites in this way.
Kitka
Doing a copy and paste in the DB can work but can also cause issues (I've dealt with them first hand).
Can you try using Duplicator so we can see if it was the migration process that caused the issue?
Basically that error is saying there should be sections but it can't find any in the DB.
That's the one! It may be worth trying just to see if it was the migration process that caused the issue.
Let me know :)
Hi Tom,
This is very unfortunate for me because I am not able to execute the duplicator plugin because it always say "error in processing". It has an issue in Godaddy. I have been trying to backup my site and tried to restore it to a localhost linux server and to another Godaddy account but unfortunately, the sections are broken and I am seeing a message saying "Warning: Invalid argument supplied for foreach() in /home/XXXXX/public_html/XXXXX/wp-content/plugins/gp-premium/sections/functions/generate-sections.php on line 197". I have tried using the method of Kitka and as what she said, I've also tried this method a lot of times already and it always work. Duplicator has issues in Godaddy and now I'm paranoid about not having a working backup.
Thanks in advance!
I've also got this another warning message in the same page i've posted above. "Warning: Invalid argument supplied for foreach() in /home/XXXXX/public_html/XXXXX/wp-content/plugins/gp-premium/sections/functions/templates/template.php on line 40"
Hoping you could help me sort this out.
Sections are saved as a serialized table in the database. When people do a search/replace for their URL in the database, it breaks serialized tables (not just Sections, but any serialized tables).
That's why plugins like BackupBuddy, Duplicator, Updraft Plus etc.. are so useful, as they take care of issues like this for you.
Those warnings are happening because the page thinks it should have sections, but those sections no longer exist in the database, most likely due to search and replacing of URLs.