[wp-trac] Re: [WordPress Trac] #8723: Instances of same class that call variable hook first generate same wp_filter_id

WordPress Trac wp-trac at lists.automattic.com
Wed Jun 24 03:55:07 GMT 2009


#8723: Instances of same class that call variable hook first generate same
wp_filter_id
------------------------------+---------------------------------------------
 Reporter:  bkrausz           |        Owner:  jacobsantos
     Type:  defect (bug)      |       Status:  reopened   
 Priority:  normal            |    Milestone:  2.8.1      
Component:  Plugins           |      Version:  2.8        
 Severity:  major             |   Resolution:             
 Keywords:  has-patch tested  |  
------------------------------+---------------------------------------------
Changes (by wnorris):

  * keywords:  has-patch tested commit => has-patch tested
  * status:  closed => reopened
  * version:  2.7 => 2.8
  * resolution:  fixed =>
  * milestone:  2.8 => 2.8.1


Comment:

 unfortunately, this patch has a major problem with objects that don't
 already have wp_filter_id set.  One value is stored as wp_filter_id on the
 object(`$filter_id_count++`), but an entirely different value is appended
 to the index that gets returned (`isset($wp_filter[$tag][$priority]) ?
 count((array)$wp_filter[$tag][$priority]) : 0;`).  Therefore, it's
 completely impossible to remove a filter on an object that was added in
 this way.

 It seems like everyone is okay with the idea of using a static counter
 variable.  If that's the case, then there is no need to mess around with
 the array size of `$wp_filter[$tag][$priority]`... just use the counter.
 And if $priority isn't being used in this manner, then it is no longer
 needed.  This actually greatly simplifies this method, as the following
 patch shows.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/8723#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list