[wp-trac] [WordPress Trac] #31392: Undefined function error on mu-plugin during update/upgrade
WordPress Trac
noreply at wordpress.org
Fri Feb 20 12:51:38 UTC 2015
#31392: Undefined function error on mu-plugin during update/upgrade
-----------------------------+-----------------------------
Reporter: jadpm | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upgrade/Install | Version: trunk
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
It seems that there is a weird issue on callbacks added to proper action
hooks inside mu-plugins. Somehow, it seems that theme and plugin functions
are not available during some actions while performing an update/upgrade.
Steps to reproduce:
Create a dummy function inside your active theme functions.php file or
create a generic plugin containing a dummy function definition:
{{{
function prefix_mu_init_callback() {
return;
}
}}}
Create a dummy mu-plugin containing a callback hooked into init and
calling that dummy function:
{{{
add_action( 'init', 'prefix_mu_init_test' );
function prefix_mu_init_test() {
prefix_mu_init_callback();
}
}}}
All in all, everything works fine. Now, if you perform an update/upgrade,
you will get the following error:
{{{
Fatal error: Call to undefined function prefix_mu_init_callback() in
C:\wamp\www\wp_dev\wp-content\mu-plugins\prefix_mu_plugin.php on line 14
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\wp_dev\wp-admin\upgrade.php:0
PHP 2. require() C:\wamp\www\wp_dev\wp-admin\upgrade.php:18
PHP 3. require_once() C:\wamp\www\wp_dev\wp-load.php:37
PHP 4. require_once() C:\wamp\www\wp_dev\wp-config.php:97
PHP 5. do_action() C:\wamp\www\wp_dev\wp-settings.php:353
PHP 6. call_user_func_array() C:\wamp\www\wp_dev\wp-
includes\plugin.php:496
PHP 7. prefix_mu_init_test() C:\wamp\www\wp_dev\wp-
includes\plugin.php:496
}}}
I managed to reproduce this issue on two different scenarios. First, doing
a manual upgrade from 3.X to 4.1.1. Also, you can easily reproduce it by
using the WordPress Beta Tester plugin, as this happens every time an
update is installed.
I am not sure whether this is indeed a bug or not, since mu-plugins should
not depend on things defined on the active theme or a third-party plugin,
so I'm using function_exists() to workaround it. But it feels like things
hooked on init should be ready to use on //real// init, that is, after
plugins_loaded and after_setup_theme.
Possible related: #28668
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31392>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list