[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
Thu Feb 2 03:56:12 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):

 I changed my class-wp-filesystem-ssh2.php as provided in #35517 and
 #37942.
 I got further as some of the obstacles were the file testing (as in exist,
 size etc).
 I got most of it fixed with using @ssh_sftp_* based functions, for example

 {{{
 public function exists($file) {
  // return file_exists( $this->sftp_path( $file ) );
  // jobst changed
  $stat = @ssh2_sftp_stat( $this->sftp_link, $file );
  if ( false === $stat ) {
   return false;
  }
  return (true);
 }
 }}}

 But now it fails at (which is a harder one to fix)

 {{{
 public function put_contents($file, $contents, $mode = false ) {
  $ret = file_put_contents( $this->sftp_path( $file ), $contents );
 }}}

 It is getting this path passed (note that this has 0770 set as it is the
 upgrade dir but still fails)

 {{{
 (ssh2.sftp://Resource id #807/{WP_INSTALL}/wp-content/upgrade/download-
 now-for-woocommerce-U6lFyT/download-now-for-woocommerce/includes/somdn-
 meta.php
 }}}

 So I tried to re-write it:

 {{{
     $fp = fopen( $this->sftp_path( $file ), "w");
     for ($written = 0; $written < strlen($contents); $written += $fwrite)
 {
       $fwrite = fwrite($fp, substr($contents, $written));
       if ($fwrite === false) {
         return $written;
       }
     }
     fclose($fp);
 }}}

 It fails at fopen, the way it is written it is really hard to do this with
 using ssh.sftp.* functions directly.

 So here is my dilemma:

 * I sit in the middle of a debate who has broken what
 * who should fix it
 * not many people are using it
 * IMHO the whole thing should be written in a way NOT using
 file_put_content and file_get_content  but ssh.sftp.* functions - then
 there would not be any problems.


 Sorry, I am grumpy.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39746#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list