WordPress.org

Ready to get started?Download WordPress

Forums

WordPress 2.8 autoupdates over SSH broken for me (2 posts)

  1. rmckern
    Member
    Posted 5 years ago #

    After upgrading, 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 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?

  2. MichaelH
    Member
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic