WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 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:

Description

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_PUBKEY','/home/ryan/.ssh/some_wordpress_key.pub');
define('FTP_PRIKEY','/home/ryan/.ssh/some_wordpress_key');
define('FTP_USER','ryan');
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_HOST','127.0.0.1:22');
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 = '' ) {
$this->debug("put_contents($file);");
$tempfile = wp_tempnam( $file );
$temp = fopen($tempfile, 'w');
if ( ! $temp )
return false;
fwrite($temp, $contents);
fclose($temp);
$ret = ssh2_scp_send($this->link, $tempfile, $file, $this->permission);
unlink($tempfile);
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 5 years ago.
wp-config.php (1.8 KB) - added by rmckern 5 years ago.

Download all attachments as: .zip

Change History (21)

comment:1 ryan5 years ago

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

comment:2 ryan5 years ago

Sorry, #10093, not 10189.

comment:3 rmckern5 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'

and

sockets

Sockets Support	enabled

Other suggestions?

comment:4 dd325 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

comment:5 rmckern5 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).

comment:6 Denis-de-Bernardy5 years ago

  • Milestone changed from Unassigned to 2.9

comment:7 ShaneF5 years ago

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

comment:8 dd325 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.

rmckern5 years ago

rmckern5 years ago

comment:9 rmckern5 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.

comment:10 dd325 years ago

Hmmmmmm..
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..

comment:11 rmckern5 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.

comment:12 follow-up: dd325 years ago

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

(This is most likely a duplicate now)

comment:13 in reply to: ↑ 12 rmckern5 years ago

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

comment:14 buzink5 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.)

comment:16 Denis-de-Bernardy4 years ago

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

comment:17 ryan4 years ago

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

comment:18 rmckern4 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.

comment:19 rmckern4 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.