Support » Fixing WordPress » Invalid argument supplied for foreach()

  • CPanel error log is giving the following warning at random intervals, anything up to 5 times per minute.

    ERROR;
    PHP Warning: Invalid argument supplied for foreach() in /home/austra45/public_html/wp-cron.php on line 117

    I have checked with my Host and they can’t find anything particular related to the error. I tried disabling plugins and that just crashed the website. I rolled it back with a restore to 16th Jan, however the error is just repeating.

    A search of forums and the net has not determined any confident fix. Would appreciate some help?

    Thanks Dennis

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter appleisle

    (@appleisle)

    PS: here is the relevant code from wp-cron.php: Line 117 in BOLD
    (Code Extract is Line 105 to Line 146)

    
     * The cron lock (a unix timestamp set when the cron was spawned),
     * must match $doing_wp_cron (the "key").
     */
    if ( $doing_cron_transient !== $doing_wp_cron ) {
    	return;
    }
    
    foreach ( $crons as $timestamp => $cronhooks ) {
    	if ( $timestamp > $gmt_time ) {
    		break;
    	}
    
    	<strong>foreach ( $cronhooks as $hook => $keys ) {</strong><em>
    
    		foreach ( $keys as $k => $v ) {
    
    			$schedule = $v['schedule'];
    
    			if ( $schedule ) {
    				wp_reschedule_event( $timestamp, $schedule, $hook, $v['args'] );
    			}
    
    			wp_unschedule_event( $timestamp, $hook, $v['args'] );
    
    			/**
    			 * Fires scheduled events.
    			 *
    			 * @ignore
    			 * @since 2.1.0
    			 *
    			 * @param string $hook Name of the hook that was scheduled to be fired.
    			 * @param array  $args The arguments to be passed to the hook.
    			 */
    			do_action_ref_array( $hook, $v['args'] );
    
    			// If the hook ran too long and another cron process stole the lock, quit.
    			if ( _get_cron_lock() !== $doing_wp_cron ) {
    				return;
    			}
    		}
    	}
    }
    

    [ Please do not bump. ]

    • This reply was modified 1 year, 3 months ago by appleisle. Reason: extra content
Viewing 1 replies (of 1 total)
  • The topic ‘Invalid argument supplied for foreach()’ is closed to new replies.