1

I'm trying to upgrade WordPress version of a blog and it fails. I input FTP info (host, user, pass and type) then I get the message:

Unable to locate WordPress Root directory.

Installation Failed.

This blog is running on Windows 2008 Enterprise host.(If it was up to me, no doubt it would be hosted on a Linux server.) My fisrt thought was that it was happening because the path is E:\home\<host_username>\Web

I can't install or upgrade plugins from WordPress admin either. Does it happen because it's hosted on a Windows server?

I've set WP_DEBUG to true on wp-config.php and tried to upgrade again. The following message repeated several times:

PHP Notice: Undefined variable: b in E:\Home\<host_username>\Web\wordpress\wp-admin\includes\class-wp-filesystem-ftpext.php on line 334

PHP Notice: Undefined variable: b in E:\Home\<host_username>\Web\wordpress\wp-admin\includes\class-wp-filesystem-ftpext.php on line 337

I've checked the wp-admin\includes\file class-wp-filesystem-ftpext.php to see what might be wrong on lines 334 and 337. Below is the code from line 334 to 337:

if ( $b['islink'] )
  $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] );

return &b;

The blog in question only has Akismet 2.5.8 active. Jetpack 2.3.3 is there, but it's not active. It's a new blog, started from WP 3.5.2. So definitely plugins must not be the cause of the problem.

And of course I know that I can upgrade WordPress uploading files of the new version over FTP. My point is I want to solve the issue of not being able to upgrade WordPress and install/upgrade plugins from its own admin.

Any ideas on how to fix it?

  • What is <host_username>? Notice how that part is missing from the file path in the notices? – s_ha_dum Aug 5 '13 at 13:04
  • 2
    Have you considered opting instead for managing updates yourself and leaving those folders unwritable by the PHP process? The gains in security are quite dramatic – Tom J Nowell Aug 5 '13 at 13:38
  • I second the comment by @TomJNowell I am not convinced that the auto-updating, while convenient, is actually a good idea for a number of reasons, security being one. – s_ha_dum Aug 5 '13 at 13:48
  • @s_ha_dum, I used <host_username> instead of the actual username, because I don't want to disclose this piece of information. – tpires Aug 5 '13 at 18:28
  • @TomJNowell, I need this WordPress feature working. – tpires Aug 5 '13 at 18:29
1

I'm sure there is another way to fix it, but you could always try to do a fresh install. Make sure you backup your database and theme files, of course, and then just drop them into the new install.

Not the most eloquent solution, but it has worked for me in the past when I couldn't think of another way.

0

Have you tried this function?

function fs_get_wp_config_path()
{
    $base = dirname(__FILE__);
    $path = false;

    if (@file_exists(dirname(dirname($base))."/wp-config.php"))
    {
        $path = dirname(dirname($base))."/wp-config.php";
    }
    else
    if (@file_exists(dirname(dirname(dirname($base)))."/wp-config.php"))
    {
        $path = dirname(dirname(dirname($base)))."/wp-config.php";
    }
    else
    $path = false;

    if ($path != false)
    {
        $path = str_replace("\\", "/", $path);
    }
    return $path;
}

Then you can get the wp root path like this:

<?php echo fs_get_wp_config_path(); ?>
0

If your Website is running on PHP 7, installing SSH SFTP Updater Support may solve your problem. This plugin works around a PHP 7 bug.

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.