Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#10195 closed defect (bug) (duplicate)

Unable to update plugins using automatic update over SSH2 since upgrade to 2.8

Reported by: rmckern Owned by: dd32
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Filesystem API Keywords: ssh2, automatic, upgrade, update
Focuses: Cc:


After upgrading to WordPress 2.8 on an Apache 2.2/Linux/PHP 5.2.9 machine, plugin and core auto-update was broken. The error returned is:

Unable to locate WordPress Content directory (wp-content).

As per standard testing, I changed permissions to various and sundry forms ranging from 775 to 777 (apache runs as a user who belongs to the group that owns all files and directories underneath the document root). That fixed nothing. I tried disabling plugins (one at a time, and then all of them) and I tried going back to a bog simple default install. I then verified that things worked perfectly under WordPress 2.7.1 with the same configuration file. I then began to dig through the wp-admin backend and the codex, and set the following in wp-config.php which should have overridden the auto-discovery and used explicit paths for wp-content and plugins:

define('FTP_PASS',''); \\ There shouldn't be a need for a password, but it doesn't make a difference with or without one for this ticket
define('FTP_BASE', '/home/ryan/path/to/my/site/public_html/');
define('FTP_CONTENT_DIR', '/home/ryan/path/to/my/site/public_html/wp-content/');
define('FTP_PLUGIN_DIR', '/home/ryan/path/to/my/site/public_html/wp-content/plugins/');

The overrides were picked up by the ssh filesystem module. I dug through /wp-admin/includes/class-wp-filesystem-base.php and found where the overrides are applied (line 138) and modified it to pick up the overrides for SSH as well (as part of the testing process):

if ( strpos($this->method, 'ftp' ) || strpos($this->method, 'ssh2' ) !== false )

This let WordPress find the wp-content directory but now I'm receiving the following:

Downloading update from http://downloads.wordpress.org/plugin/stats.1.4.zip.

Unpacking the update.

Could not copy file /home/ryan/path/to/my/site/public_html/wp-content/upgrade/stats.1.410/stats/screenshot-1.png

I've now traced that down through /wp-admin/includes/file.php and /wp-admin/includes/class-wp-filesystem-ssh2.php to the following failing function (lines 177 through 180 of class-wp-filesystem-ssh2.php):

function put_contents($file, $contents, $type = '' ) {
$file = ltrim($file, '/');
return file_put_contents('ssh2.sftp://' . $this->sftp_link .'/' . $file, $contents);

This is markedly simpler, and more direct than it was in 2.7.1:

function put_contents($file, $contents, $type = '' ) {
$tempfile = wp_tempnam( $file );
$temp = fopen($tempfile, 'w');
if ( ! $temp )
return false;
fwrite($temp, $contents);
$ret = ssh2_scp_send($this->link, $tempfile, $file, $this->permission);
return $ret;

The downside to this simplicity is that it doesn't bloody work on my system.
I'm just about stumped now, and I'm ready to cry uncle. Can anyone, at all, make heads or tails of what the hell is going on?

Attachments (2)

phpinfo.html (73.7 KB) - added by rmckern 12 years ago.
wp-config.php (1.8 KB) - added by rmckern 12 years ago.

Download all attachments as: .zip

Change History (21)

#1 @ryan
12 years ago

See #10189. Sounds like this could be the same issue.

#2 @ryan
12 years ago

Sorry, #10093, not 10189.

#3 @rmckern
12 years ago

Sockets are enabled. Here's the snippet from phpinfo():

'./configure' '--host=i686-redhat-linux-gnu' '--build=i686-redhat-linux-gnu' '--target=i686-redhat-linux' '--enable-sockets'



Sockets Support	enabled

Other suggestions?

#4 @dd32
12 years ago

  • Component changed from Upgrade/Install to Filesystem

Sockets are not needed at all.

Using the ssh2.sftp wrapper is much faster and efficient than using the temp file + scp send method (by as much as a half in processing time required)..

Can you check your phpinfo to see if the ssh2.sftp wrapper is available? It should be available if you've compiled the SSH2 extension (OR at least, any recent version of it) yourself.

If you could post the entire phpinfo somewhere i can see it that'd be great, you can email it if you want, WordPress @ dd32.id.au

#5 @rmckern
12 years ago

I'm not bashful. It's available at https://secure.orangefort.com/util/phpinfo.php.
I'm assuming that'd be this part, listed here:

Registered PHP Streams	php, file, data, http, ftp, compress.bzip2, compress.zlib, https, ftps, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp, zip

Please let me know if you're seeing something off. I did build and install ssh2 from PECL, and I tried reinstalling it when things blew up (to no avail).

#6 @Denis-de-Bernardy
12 years ago

  • Milestone changed from Unassigned to 2.9

#7 @ShaneF
12 years ago

Werid. I have no had any problems with ssh2 upgrades other than the sockets problem I mentioned in #10093 for a check.

#8 @dd32
12 years ago

It's available at https://secure.orangefort.com/util/phpinfo.php.

That requires a login.

I'm not sure why you're having a problem to be honest.. Can you enable WP_Debug and see if any warnings/notices are thrown?

define('WP_DEBUG', true); //In your wp-config.php file.

12 years ago

12 years ago

#9 @rmckern
12 years ago

My apologies. I must have that password saved, since I haven't seen the login prompt in so long. I'm attaching my phpinfo output to this ticket, as well as a sanitized version of wp-config.php.

I've enabeld debug, and double checked that I am running an unmodified 2.8 tree (without the modifications I'd made to /wp-admin/includes/class-wp-filesystem-base.php, which I mentioned in my initial report, but with the same wp-config file). I've installed the stats plugin, version 1.3.8, and after attempting to automatically upgrade I still receive:

Unable to locate WordPress Content directory (wp-content).

There is also nothing about this being thrown to the site's error log.

#10 @dd32
12 years ago

The only thing i can think of is to attempt disabling Suhosin and see if thats affecting anything.

I'll try to setup a similar environment (Config wise) and see if i can duplicate it..

#11 @rmckern
12 years ago

I've installed PHP without the suhosin patch or module loaded in, and I'm still receiving this error with no warnings or details thrown to either the page or the error log.

#12 follow-up: @dd32
12 years ago

rmckern: Can you see if #10604 fixes your problems?

(This is most likely a duplicate now)

#13 in reply to: ↑ 12 @rmckern
12 years ago

After applying the patch in #10604 attempts to update still return "Unable to locate WordPress Content directory (wp-content)."

#14 @buzink
12 years ago

(In the original text 'The overrides were picked up by the ssh filesystem module' should be 'The overrides were picked up by the ftp filesystem module', i think.)

#16 @Denis-de-Bernardy
12 years ago

I think we can safely close this one as dup of #11152.

#17 @ryan
12 years ago

  • Milestone 2.9 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

#18 @rmckern
12 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened
  • Version changed from 2.8 to 2.9

I've updated to Wordpress 2.9 beta 2, and I still receive the following:

Enabling Maintenance mode.

Unable to locate WordPress Content directory (wp-content).

Unable to locate WordPress Content directory (wp-content).

I will attempt to obtain some log data, but this if this is a dupe of #11152 then #11152 isn't actually fixed.

#19 @rmckern
12 years ago

  • Resolution set to duplicate
  • Status changed from reopened to closed

... Scratch that. Worked through upgrade a little more and solved it. It is fixed, and it likely was a dupe.
My mistake!

Note: See TracTickets for help on using tickets.