[wp-trac] [WordPress Trac] #39746: Suddenly getting error on all of my servers: Unable to locate WordPress content directory (wp-content).
WordPress Trac
noreply at wordpress.org
Tue Mar 7 05:44:07 UTC 2017
#39746: Suddenly getting error on all of my servers: Unable to locate WordPress
content directory (wp-content).
-----------------------------+------------------------------
Reporter: jobst | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upgrade/Install | Version: 4.7.2
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+------------------------------
Comment (by jobst):
Replying to [comment:5 dd32]:
> Thanks @jobst, this could be something similar to #35517.
>
> I don't think that this is anything to do with WordPress and is more
likely that the libssh build you're using isn't compatible with either php
or your ssh server.
> This probably needs someone to duplicate it outside of WordPress and
reported upstream to their bug tracker.
IMHO it is both Wordpress and pecl networking ssh2, and it is fixable.
I basically followed the instructions as laid out in these two links and
it works for me:
* https://core.trac.wordpress.org/attachment/ticket/35517/class-wp-
filesystem-ssh2.php.patch
* https://github.com/php/pecl-networking-
ssh2/commit/17680cf039f0cfac53b5a2531fdb715b95e9cc42
My take on Wordpress and it's IMHO:
If you look at the pecl resource above it shows that after after php
7.0.28 and php 5.6.28 there is a need for "clean id" for function calls
when using ssh2.sftp://, not an object as in "Resource #447" but just
"447".
I have tried to implement this in "class-wp-filesystem-ssh2" like so:
{{{
public function sftp_path( $path ) {
error_log(__FUNCTION__.": LINK >".$this->sftp_link."< PATH >$path<");
if ( '/' === $path ) {
$path = '/./';
}
// not working
$RetVal=print_r($this->sftp_link,true);
error_log("RetVal >$RetVal<");
$pos=strpos($RetVal,"Resource id",0);
error_log("POS >".$pos."<");
if($pos!==false)
{
error_log("YEP, object found");
$RetVal = str_replace("Resource id #","",$RetVal);
$RetVal = "ssh2.sftp://" . $RetVal . "/" . ltrim( $path, "/");
error_log("RetVal >$RetVal<");
return $RetVal;
}
else
{
// else
error_log("NO, not object");
return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/'
);
}
}
}}}
but I could not get this to work :-(, it made no change.
So when I look at the code in "class-wp-filesystem-ssh2.php" there are
already many functions used from the ssh2_sftp library (i.e.
ssh2_sftp_realpath), so why not using one extra one called
"ssh2_sftp_stat()" to return values for "exists(), is_file(), is_dir(),
is-readable(), atime(), mtime()"? This way one can be sure that the values
returned are correct! So I followed the instructions (35517) and changed
my file and it works!
My take on Pecl Networking ssh2:
I added some extra lines to the the file ssh2_fopen_wrappers.c from the
pecl tar.gz just to see whether I was interpreting the code correctly, and
yes ALL IT DOES chopping the "Resouce id#" from the string before using
it:
{{{
bcgFile=fopen("/var/log/openwrapper.log", "a");
if(bcgFile==NULL) {
perror("Error opening file.");
}
/* Starting with 5.6.28, 7.0.13 need to be clean, else php_url_parse
will fail */
char *tmp = estrdup(path);
fprintf(bcgFile, "BEFORE %s BEFORE\n", tmp);
strncpy(tmp + (h-path), h + sizeof("Resource id #")-1,
strlen(tmp)-sizeof("Resource id #"));
fprintf(bcgFile, " AFTER %s AFTER", tmp);
resource = php_url_parse(tmp);
efree(tmp);
fclose(bcgFile);
}}}
I can only say it works, I tried it on a number of installs, no problem.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39746#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list