-
AuthorPosts
-
March 1, 2020 at 2:53 pm #1189215
Hi,
I’ve been getting the following warning message using Version 4.7.3
Warning: Invalid argument supplied for foreach() in /public_html/gbshealthandsafety.co.uk/wp-content/themes/enfold/includes/helper-assets.php on line 342
The message appears in the log file of the Error Log Monitor plugin Version 1.6.9 I use on the gbshealthandsafety.co.uk site
How do I go about tracking down the cause of this message ?
Mike
March 2, 2020 at 5:31 am #1189333Hey Mike,
Please send us a temporary WordPress admin login and login URL so that we can have a closer look. You can post the details in the Private Content section of your reply.
Best regards,
RikardMarch 2, 2020 at 1:23 pm #1189420This reply has been marked as private.March 10, 2020 at 5:00 am #1191689Hi,
Sorry for the delay. Is the error happening intermittently, or do you notice any kind of pattern as to when it occurs? We tried to access the site, but the login token above has already expired. Please generate another token with a longer duration.
Thank you for your patience.
Best regards,
IsmaelMarch 10, 2020 at 10:04 am #1191752Hi,
I’ve not noticed a pattern, or anything unusual at the front end – but the error logs show that the problem arises, occasionally, every few days
I’ve created – an attached – a login extended for another week
Please let me know if you’d like a further extension.
Regards,
Mike
March 11, 2020 at 4:50 am #1192124Hi,
Thank you for the update.
The issue occurs when the theme tries to check if there are video elements in the posts. It tries to loop through the global $posts variable but for some reason it’s empty or undefined, and thus the error. Please edit the functions.php file, and look for this code around line 445:
if( 'force_mediaelement' != $opt_mediaelement ) { $condition = ( $opt_mediaelement != "disable_mediaelement" ) && av_video_assets_required(); }
Above, add this code:
global $posts;
Or just remove the av_video_assets_required completely.
if( 'force_mediaelement' != $opt_mediaelement ) { $condition = ( $opt_mediaelement != "disable_mediaelement" ); }
Best regards,
IsmaelApril 2, 2020 at 7:33 pm #1200276I just noticed we have this same issue… why is the “global $posts;” not standard in the theme as a fix for this? If I have to manually change this with every update overwriting it, that’s weird… Do a search for “helper-assets.php” and you see this issue comes up a lot on the forums.
April 6, 2020 at 5:36 am #1201132Hi,
@milkboy31: Does the modification above fix the issue in your installation? The error doesn’t really occur on our end, so it’s probably server related or an issue with a plugin.Best regards,
IsmaelApril 8, 2020 at 9:02 pm #1202011It has not solved it for us, no. Started seeing errors in early December 2019… we see them daily but not sure what triggers them. I just cleared our logs and loaded our homepage with a video background in a color section, then loaded a page with a vimeo embed… no errors. That said, I also am now using a CDN for content, so it may not have tripped that on the local server.
April 13, 2020 at 8:30 am #1203247Hi,
Thank you for the info.
Did you enable the Performance > File Compression settings? And did you toggle it or disable it temporarily after doing the modification above? It’s possible that the site is still loading the older compressed version of the scripts, and without the changes above.
Best regards,
IsmaelApril 15, 2020 at 10:22 pm #1204190I disabled that, cleared caches, etc… then re-enabled it. I thought maybe it helped, but no, a day later I had another few dozen errors.
April 20, 2020 at 6:14 am #1205392Hi,
@milkboy31: Thank you for the info. Would you mind creating another thread/ticket and provide the details in the private field? Please attach the URL of this thread for reference. We’ll close it for now.Best regards,
Ismael -
AuthorPosts
- The topic ‘PHP Warning message’ is closed to new replies.