[wp-trac] [WordPress Trac] #39338: class-wp-hook.php - apply_filters() infinite loop

WordPress Trac noreply at wordpress.org
Tue Dec 20 08:16:26 UTC 2016


#39338: class-wp-hook.php - apply_filters() infinite loop
--------------------------+-----------------------------
 Reporter:  frettled      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Plugins       |    Version:  4.7
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I just saw nearly 60 million error log entries (17 GB) due to this bug.

 In line 303 of class-wp-hook.php, there is a piece of code that will cause
 an infinite loop:

 {{{#!php
 } while ( false !== next( $this->iterations[ $nesting_level ] ) );
 }}}

 The problem is that
 {{{#!php
 $this->iterations[ $nesting_level ]
 }}}
 can be null.

 Suggested fix:

 {{{#!php
 } while ( ! is_null( $this->iterations[ $nesting_level ] ) && false !==
 next( $this->iterations[ $nesting_level ] ) );
 }}}

 I also urge developers to look for similar "false !== next()" constructs
 in code, as they '''will''' lead to infinite loops.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39338>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list