[wp-trac] [WordPress Trac] #38116: Introduce is_callable check into apply_filters function to avoid failure of call_user_func_array causing all filters to fail.

WordPress Trac noreply at wordpress.org
Tue Sep 20 21:30:45 UTC 2016


#38116: Introduce is_callable check into apply_filters function to avoid failure of
call_user_func_array causing all filters to fail.
-----------------------------+-----------------------------
 Reporter:  garrett-eclipse  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  General          |    Version:  4.6.1
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 Hello,

 Just wanted to suggest an improvement for the apply_filters function to
 avoid failures introduced by custom code or plugins that invalidly set an
 add_filter without providing the scope or misspelling the function.

 Currently if a filter is applied incorrectly... in the case I came across
 I had a custom plugin which I missed wrapping the array($this,) around the
 function name. This caused an error in debug for call_user_func_array
 expecting valid callback. Due to this NULL is returned and all other
 filters are basically ignored.

 Would be nice to do an is_callable check before execution of the
 call_user_func_array so as to skip any broken add_filters applied. I'd say
 still log an error so people can troubleshoot and find out why their
 filter failed, but would be nicer than returning null.

 Thank you

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


More information about the wp-trac mailing list