Opened 5 weeks ago
Last modified 5 weeks ago
#62963 new defect (bug)
Fatal is_admin_bar_showing() - Call to undefined function is_user_logged_in()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Toolbar | Keywords: | |
Focuses: | Cc: |
Description
When hooking a callback on e.g. "muplugins_loaded" or on "shutdown" from an mu-plugin, object cache or advanced cache and checking "is_admin_bar_showing()", you can get a fatal bc pluggable.php which is called isn't loaded yet.
Either add a function exists check for "is_user_logged_in" or load pluggable.php early?
Change History (5)
#2
@
5 weeks ago
shutdown occurs after the page may be output to the browser.
shutdown also happens if there's an uncaught exception for example, in which case there will never be an "init" hook if the exception happens before that.
EDIT: when WP loads a function, it needs to make sure that all things it calls have been loaded already or it will load them itself
EDIT2: or if an (mu-)plugin or theme calls exit, shutdown is called long before the init hook.
#4
@
5 weeks ago
- Component changed from Administration to Toolbar
is_admin_bar_showing()
runs the is_user_logged_in()
condition if $show_admin_bar
is not set (after checking whether it is an XML-RPC/Ajax/iframe/JSON request, an embed, or within the admin).
Could you use show_admin_bar( false );
somehow?
Calling certain functions before
init
runs is not advised, and can lead to fatal errors like you've experienced.muplugins_loaded
shouldn't be anything other than the very first plugin bootstrap functionality (such as adding filters), The WordPress user is not loaded at that time (So you can't check if a user setting is valid), andshutdown
occurs after the page may be output to the browser.To me, it feels like the code you're running might be the problem, and should be delayed until
init
or later.Can you provide example code that shows the behaviour in a way which should be supported?