• Hi,

    We have noticed two recent cases of an infinite loop in the plugin.php code.

    PHP Warning:  reset() expects parameter 1 to be array, boolean given in /wp_dir/wp-includes/plugin.php on line 400
    PHP Warning:  current() expects parameter 1 to be array, boolean given in /wp_dir/wp-includes/plugin.php on line 403
    next() expects parameter 1 to be array, boolean given in /wp_dir/wp-includes/plugin.php on line 407
    PHP Warning:  current() expects parameter 1 to be array, boolean given in /wp_dir/wp-includes/plugin.php on line 403
    next() expects parameter 1 to be array, boolean given in /wp_dir/wp-includes/plugin.php on line 407
    -- infinity --

    Not sure why $wp_filter[$tag] is getting set to a boolean, but there is no check in the code to make sure it is an array before this loop is entered:

    do {
        foreach ( (array) current($wp_filter[$tag]) as $the_ )
          if ( !is_null($the_['function']) )
            call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    
      } while ( next($wp_filter[$tag]) !== false );

    We support many sites so it is hard to pin down what has changed. We will do more debugging to see if we can find what is causing the issue.

    I wrote mainly because I think it is sort of dangerous to have this type of a loop given you don’t always know that the thing coming in is truly an array. Perhaps a future version of WP could include a check for an array first? I notice this looping construct exists in several other places in plugin.php.

    Thanks for creating such a terrific product. I’d be happy to provide any additional information if needed.

Viewing 1 replies (of 1 total)
  • Matt Fiocca

    (@mattfioccagmailcom)

    I was having the same issue and came across this post. My logs were clogged with 1GB+ of these error lines. I’m sure you came to the same fix, but i just wanted to post this for semantics sake. change

    while ( next($wp_filter[$tag]) !== false );

    to:

    while ( is_array($wp_filter[$tag]) && next($wp_filter[$tag]) !== false );
Viewing 1 replies (of 1 total)
  • The topic ‘plugin.php and wp_filter causing an infinite loop’ is closed to new replies.