Make WordPress Core

Opened 3 years ago

Last modified 5 months ago

#38116 new defect (bug)

Introduce is_callable check into apply_filters function to avoid failure of call_user_func_array causing all filters to fail.

Reported by: garrett-eclipse Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.6.1
Component: Plugins Keywords:
Focuses: Cc:
PR Number:



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

Change History (1)

#1 @desrosj
5 months ago

  • Component changed from General to Plugins
Note: See TracTickets for help on using tickets.