[wp-trac] [WordPress Trac] #30802: General settings menu isn't opened.

WordPress Trac noreply at wordpress.org
Sun Mar 8 00:24:30 UTC 2015


#30802: General settings menu isn't opened.
----------------------------+--------------------
 Reporter:  hyoseop         |       Owner:
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  4.1.2
Component:  Filesystem API  |     Version:  4.1
 Severity:  normal          |  Resolution:
 Keywords:  needs-patch     |     Focuses:
----------------------------+--------------------

Comment (by jobst):

 Hi hyoseop

 This issue ONLY occurs when the following two conditions are met
 * You have specified the FTP setting in wp-config.php
 * You have NO languages directory below /PATH_TO_WORDPRESS/wp-content/

 See BUG 31554 for deeper explanation.

 MY RESEARCH INTO THIS:

 It took me some tracing to find that the error was created in
 /PATH_TO_WP_INSTALL/wp-admin/includes/class-wp-upgrader.php in the
 function fs_connect in the switch statement "default" case. I included a
 debug statement in that function right at he beginning to see what path
 generated this error:
 {{{
  error_log(" FS_CONNECT: ".print_r($directories,1));
 }}}
 which gave me this output on fail:
 {{{
 [07-Mar-2015 06:44:40 UTC]  FS_CONNECT: Array
 (
     [0] => /PATHDELETED/wp-content
     [1] => /PATHDELETED/wp-content/languages
 )
 }}}
 while the APACHE /var/log/httpd/error_log displayed this:
 {{{
 [Sat Mar 07 17:44:40 2015] [notice] child pid 578 exit signal Segmentation
 fault (11)
 }}}
 It took me some time to get to the real problem:

 * When the function "fs_connect" (see a couple of lines above) is called,
 it calls a function find_folder($dir) where $dir is (when the seg fault is
 called) "/PATHDELETED/wp-content/languages".

 * find_folder resides in /PATHDELETED/wp-admin/includes/class-wp-
 filesystem-base.php on line 222. If this function cannot find the folder
 after some 30 lines of code tried to find it, the function employs another
 function called "seach_for_folder()" which is in the same file on line
 291.

 * Right at the start of that function "seach_for_folder()" there is an if
 statement checking whether $base is empty or '.', if either it sets $base
 = railingslashit($this->cwd()); which actually is the bug.

 * all trailingslashit does appending a "/" to the end of the string
 returned by $this->cwd() - however $this->cwd() returns a string that
 includes a "\n", this crashes wordpress with a segfault so in fact the
 return string has a newline character in between the string and the /

 FAULTY EXAMPLE
 {{{
 if ( empty( $base ) || '.' == $base )
   $base = trailingslashit($this->cwd());
 error_log("BASE: ".$base);

 BASE: /home/ssh_user_name
 /
 }}}
 CHANGED CODE TO FIX THE BUG:
 {{{
 if ( empty( $base ) || '.' == $base )
 {
   $tmp=$this->cwd();
   $tmp=preg_replace("/[\r\n\m\t]/","",$tmp);
   $base = trailingslashit($tmp);
 }
 echo "BASE: $base"

 BASE: /home/ssh_user_name/
 }}}
 The last example does not SEGFAULT the system.

 Jobst

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


More information about the wp-trac mailing list