[wp-trac] [WordPress Trac] #15296: Filters don't check that the function is callable

WordPress Trac wp-trac at lists.automattic.com
Tue Nov 2 18:02:17 UTC 2010


#15296: Filters don't check that the function is callable
---------------------------+------------------------------------------------
 Reporter:  aaroncampbell  |       Owner:                 
     Type:  defect (bug)   |      Status:  new            
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Performance    |     Version:  3.0            
 Severity:  normal         |    Keywords:  dev-feedback   
---------------------------+------------------------------------------------
 This is a problem that I found in Shopp.  Basically, they used
 `add_filter('redirect_canonical', 'canonical_home');` when it should have
 been `add_filter('redirect_canonical', array( $this, 'canonical_home'
 ));`, so the function added to `redirect_canonical` didn't actually exist.
 However, it's still called and NULL is always returned, so the canonical
 redirects completely stopped working.

 It seems like we should add an `is_callable` test to either
 `apply_filters` or `add_filter`.  I'd prefer to see it on `apply_filters`
 simply because more filters are added than are actually run.

 As Nacin pointed out, this is additional execution and our filters need to
 stay lean and mean.  Still, I see both sides to this so I thought I'd try
 to get some feedback from other devs.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15296>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list