0

I'm trying to upgrade WordPress to the latest 4.2.2. On the screen, I'm seeing:

Downloading update from https://downloads.wordpress.org/release/wordpress-4.2.2-no-content.zip…
Unpacking the update…
Could not create directory.
Installation Failed

And in the php error log, I get

 PHP Fatal error:  Call to undefined function add_action() in /home/userhome/public_html/wp-content/themes/launchframe/functions.php on line 81, referer: http://example.com/wp-admin/update-core.php?action=do-core-upgrade

What appears to be happening is the theme functions.php file is being included instead of the wp-includes/functions.php. This is new though - previous upgrades have gone fine. I've tried including the "missing" files in my theme's functions.php (i.e.)

require_once('/home/userhome/public_html/wp-includes/plugin.php');
require_once('/home/userhome/public_html/wp-includes/theme.php');
require_once('/home/userhome/public_html/wp-includes/shortcodes.php');
require_once('/home/userhome/public_html/wp-includes/media.php');

But ultimately that failed because more and more files ended up being referenced. I also tried calling wp-load.php from my theme's functions.php file, but that ended up loading my theme again and got "function already defined" errors.

Any suggestions?

Thanks

  • Why not deactivate your theme and update WP first and then activate your theme again? – Wali Hassan May 14 '15 at 21:39
  • You have something else installed that makes your theme functions.php to be included before the WordPress bootstrap that normal would not happen. You should check also for all your plugins or if alterations to any of the core files where made, as the theme's functions file is always loaded after the basic WordPress bootstrap is done and actions and filters API is already available at that moment. – Gabb3 Oct 14 '15 at 7:03
1

I am not confident your guess at "being included instead" is accurate. The inclusion of core file is hardcoded in wp-settings.php pretty hard, it would be extremely challenging to subvert under normal circumstances.

I have trouble imaging scenario in which functions.php of the theme will be loaded, but add_action() will be unavailable. This simply shouldn't ever happen under normal mechanics.

My best guess is that your installation is strangely customized or otherwise corrupt.

I would start looking into specifics of strange theme's functions.php load, probably by dumping wp_debug_backtrace() from there for starters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.