[wp-trac] [WordPress Trac] #19986: Issue with add_filter() and add_action() when using anonymous functions.

WordPress Trac wp-trac at lists.automattic.com
Wed Feb 8 01:04:41 UTC 2012


#19986: Issue with add_filter() and add_action() when using anonymous functions.
--------------------------+------------------------------
 Reporter:  pagesimplify  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Plugins       |     Version:  3.3.1
 Severity:  minor         |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------------------
Changes (by pagesimplify):

 * cc: pagesimplify (added)


Comment:

 Unfortunately, I noticed this in January 2011 and applied this patch to my
 WordPress installation then. So it's been a long while since I have
 observed the various conditions where I noticed this being an issue. I can
 say that I recall the issues were noticeable more between plugin/widget
 configurations for certain pages than between different system
 environments.

 If I stretch my mental muscles just a bit more, I recall suspecting the
 issue was related to  the combination of several properly named functions
 registered with an anonymous function, or perhaps multiple anonymous
 functions for a specific filter tag. I discovered the issue when
 attempting to step through code in a plugin that wasn't running properly.
 As I moved the break points up the possible callstack to the apply_filters
 function, I noticed I could never step past a certain number of function
 calls in the apply filters loop. This was because the apply_filter
 function could not retrieve the array item stored with an invalid array
 key name. I can't recall if this would work if no other functions were
 registered or if it was the last item in the array.

 In this specific case, I do recall that by removing some widgets from a
 page or by deactivating other plugins, I could get the problematic filter
 to run. However, this is still anecdotal in that I never tested to isolate
 all conditions for this issue to occur. Once I isolated the issue while
 troubleshooting Otto's SFC plugin, I simply applied the fix and the very
 random issues I previously experienced were no longer an issue.

 It may also be helpful to know I mostly run multisite installations and
 will manage many blogs running in the same network. So, I was encountering
 random issues with many different sites on the same network using
 different themes, activated plugins, and widget configurations. Again,
 problems went away after applying the trim() function to the string return
 value.

 Hopefully, this can resolve a lot of random issues people experience with
 no real explanation.

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


More information about the wp-trac mailing list