Opened 3 years ago
Last modified 3 years ago
#55415 new defect (bug)
Pluggable.php file is causing Fatal Errors
Reported by: | ceceet | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | major | Version: | |
Component: | Plugins | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
I'm facing an issue with my WordPress install. I have two plugins getting a PHP Fatal Error due to the pluggable.php file on my site using PHP 8.0. My host is Closte (closte.com). The host doesn't allow changes to WP core files. The plugin developers are saying that the issue is WordPress and not the plugin. I'm using the latest versions of the plugins and the latest version of WP. Here is the error I'm seeing:
- PHP Fatal error: Uncaught Error: Call to undefined function wp_get_current_user() in /wp-content/plugins/updraftcentral/site-management.php:486
Would really prefer not to downgrade my PHP version so any help would be appreciated.
Change History (8)
#2
in reply to:
↑ 1
@
3 years ago
Replying to afragen:
The solution is to call your code in a callback from a hook like (
init
,admin_init
,plugins_loaded
) etc.
Cool, thanks. I'll give that a shot.
#3
follow-up:
↓ 5
@
3 years ago
- Component changed from Upgrade/Install to Plugins
- Keywords reporter-feedback added
Hi @ceceet! Welcome to Trac and thanks for opening this ticket.
Some additional info:
- The UpdraftCentral plugin calls
wp_get_current_user()
in ashutdown
callback. - See here for the call and for the hook.
- This has existed within the plugin for quite a long time.
I created a small plugin to test calling wp_get_current_user()
in a shutdown
callback:
<?php /** * Plugin Name: #55415 - `wp_get_current_user()` in a `shutdown` callback. * Description: Runs `wp_get_current_user()` in a `shutdown` callback. * Author: WordPress Contributors */ add_action( 'shutdown', 'try_wp_get_current_user' ); function try_wp_get_current_user() { wp_get_current_user(); }
There was no Fatal Error on PHP 7.4 or PHP 8.0.
@ceceet if you have any additional information from the plugin developers about how they determined that this is an issue within WordPress Core rather than the plugin, that would be a big help in determining how best to resolve this issue.
#4
follow-up:
↓ 6
@
3 years ago
Hi there, welcome to WordPress Trac! Thanks for the ticket.
The plugin developers are saying that the issue is WordPress and not the plugin.
It looks like the issue comes from the UpdraftCentral Dashboard plugin. Could the plugin authors explain what they think the issue is?
Generally, this can happen if the plugin calls the wp_get_current_user()
function too early. The solution to that, as noted above, would be to call it on the plugins_loaded
hook or later.
In this case, however, the plugin calls wp_get_current_user()
in the UpdraftCentral::schedule_event() method, which is attached to the 'shutdown' hook. This should be OK, so there might be other things involved here. Maybe the error is only triggered when WordPress is loaded in the SHORTINIT
mode (which skips most of the APIs), or maybe it's triggered by another plugin.
#5
in reply to:
↑ 3
@
3 years ago
Replying to costdev:
Hi @ceceet! Welcome to Trac and thanks for opening this ticket.
Some additional info:
- The UpdraftCentral plugin calls
wp_get_current_user()
in ashutdown
callback.- See here for the call and for the hook.
- This has existed within the plugin for quite a long time.
I created a small plugin to test calling
wp_get_current_user()
in ashutdown
callback:
<?php /** * Plugin Name: #55415 - `wp_get_current_user()` in a `shutdown` callback. * Description: Runs `wp_get_current_user()` in a `shutdown` callback. * Author: WordPress Contributors */ add_action( 'shutdown', 'try_wp_get_current_user' ); function try_wp_get_current_user() { wp_get_current_user(); }There was no Fatal Error on PHP 7.4 or PHP 8.0.
@ceceet if you have any additional information from the plugin developers about how they determined that this is an issue within WordPress Core rather than the plugin, that would be a big help in determining how best to resolve this issue.
Thanks for the detailed response! I submitted a support ticket to updraft and they just decided it was a problem the pluggable.php and not anything on their end. I kinda think they're full of it but thought I'd post here first. They didn't log into the site and try to change anything so I don't know how they really came to that decision.
#6
in reply to:
↑ 4
@
3 years ago
Thanks for the detailed response! I submitted a support ticket to updraft and they just decided it was a problem with the pluggable.php and not anything on their end. I kinda think they're full of it but thought I'd post here first. They didn't log into the site and try to change anything so I don't know how they really came to that decision.
Replying to SergeyBiryukov:
Hi there, welcome to WordPress Trac! Thanks for the ticket.
The plugin developers are saying that the issue is WordPress and not the plugin.
It looks like the issue comes from the UpdraftCentral Dashboard plugin. Could the plugin authors explain what they think the issue is?
Generally, this can happen if the plugin calls the
wp_get_current_user()
function too early. The solution to that, as noted above, would be to call it on theplugins_loaded
hook or later.
In this case, however, the plugin calls
wp_get_current_user()
in the UpdraftCentral::schedule_event() method, which is attached to the 'shutdown' hook. This should be OK, so there might be other things involved here. Maybe the error is only triggered when WordPress is loaded in theSHORTINIT
mode (which skips most of the APIs), or maybe it's triggered by another plugin.
#7
follow-up:
↓ 8
@
3 years ago
I installed the plugin into 6.0-alpha (tested on PHP 8.0 and PHP 7.4) and I didn't get any errors before or after adding the shortcode as instructed.
Maybe the error is only triggered when WordPress is loaded in the
SHORTINIT
mode (which skips most of the APIs), or maybe it's triggered by another plugin.
This is a good next step. @ceceet Have you tried disabling all other plugins and switching to a default theme?
#8
in reply to:
↑ 7
@
3 years ago
I currently have this installed on a multisite, so updraft only runs on the network admin as far as I know. I could try to disable the theme I'm using on the main site to see if that makes a difference if you think it would work.
Replying to costdev:
I installed the plugin into 6.0-alpha (tested on PHP 8.0 and PHP 7.4) and I didn't get any errors before or after adding the shortcode as instructed.
Maybe the error is only triggered when WordPress is loaded in the
SHORTINIT
mode (which skips most of the APIs), or maybe it's triggered by another plugin.
This is a good next step. @ceceet Have you tried disabling all other plugins and switching to a default theme?
The solution is to call your code in a callback from a hook like (
init
,admin_init
,plugins_loaded
) etc.