Title: plugin.php and wp_filter causing an infinite loop
Last modified: August 20, 2016

---

# plugin.php and wp_filter causing an infinite loop

 *  [ewendland](https://wordpress.org/support/users/ewendland/)
 * (@ewendland)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/pluginphp-and-wp_filter-causing-an-infinite-loop/)
 * 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](https://wordpress.org/support/users/mattfioccagmailcom/)
 * (@mattfioccagmailcom)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/pluginphp-and-wp_filter-causing-an-infinite-loop/#post-2990776)
 * 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.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [Matt Fiocca](https://wordpress.org/support/users/mattfioccagmailcom/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/pluginphp-and-wp_filter-causing-an-infinite-loop/#post-2990776)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
