Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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

    #1189333

    Hey 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,
    Rikard

    #1189420
    This reply has been marked as private.
    #1191689

    Hi,

    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,
    Ismael

    #1191752

    Hi,

    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

    #1192124

    Hi,

    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,
    Ismael

    #1200276

    I 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.

    #1201132

    Hi,


    @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,
    Ismael

    #1202011

    It 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.

    #1203247

    Hi,

    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,
    Ismael

    #1204190

    I 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.

    #1205392

    Hi,


    @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

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘PHP Warning message’ is closed to new replies.