[wp-trac] [WordPress Trac] #40156: Warning for invalid hook callback is not very useful
WordPress Trac
noreply at wordpress.org
Tue Mar 14 23:07:40 UTC 2017
#40156: Warning for invalid hook callback is not very useful
-------------------------+-----------------------------
Reporter: Shelob9 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 0.71
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
If you add a hook with an uncallable callback, an error like `Warning:
call_user_func_array() expects parameter 1 to be a valid callback,
function 'not_a_function' not found or invalid function name in` is shown.
This is technically correct, but not useful. When I say useful, I don't
think it is useful to the following user profiles:
1) Non-technical user seeing errors. A non-developer might no what a
WordPress hook is, but not how it works internally. Therefore they are not
likely to understand this error is related to a hook. They are not given
good information, and might be missing a clue as to who to ask for support
(plugin or theme developer, host, etc.)
2) New developer. A developer new to WordPress might not understand yet
what a hook is or that a missing callback generates this type of error. A
more clear error will help guide their googling for the error and/ or help
them find the issue in the code.
3) Experienced WordPress developer. When I see this error, I assume there
is a non-callabale hook callback. But `call_user_func()` has other uses so
it might be misleading to me.
I think it would be way more helpful if the error triggered was something
like `Hook $hook_name could not call $callback` or `The callback function
$hook, registered for $hook_name is not callabale`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40156>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list