• replace
    return file_put_contents(‘ssh2.sftp://’ . $this->sftp_link . ‘/’ . $file, $contents);

    with

    if (file_put_contents(‘ssh2.sftp://’ . $this->sftp_link . ‘/’ . $file, $contents)!==FALSE)
    return true;
    else
    return false;

    because if file is empty (0 bytes) it is not working. It returns 0, which later is considered to be false. So, do explicit check and return correct value. Check the documentation on file_put_contents.

  • The topic ‘Bug and bugfix in class-wp-filesystem-ssh2.php’ is closed to new replies.