WordPress.org

Make WordPress Core

Ticket #5586: 5586.15.diff

File 5586.15.diff, 3.8 KB (added by DD32, 13 years ago)

Support certain Dedicated server setups.

  • wp-admin/includes/class-wp-filesystem-ftpext.php

     
    8484                $this->permission = $perm;
    8585        }
    8686
    87         function find_base_dir($base = '.',$echo = false) {
     87        function find_base_dir($base = '.',$echo = false, $loop = false) {
    8888                //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
    8989                $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
    9090                if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
     
    9898
    9999                //Can we see the Current directory as part of the ABSPATH?
    100100                $location = strpos($abspath, $base);
    101                 if( false !== $location ){
     101                if( false !== $location ) {
    102102                        $newbase = path_join($base, substr($abspath, $location + strlen($base)));
    103103
    104104                        if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly.
     
    126126                                //Lets try that folder:
    127127                                $folder = path_join($base, $key);
    128128                                if($echo) printf( __('Changing to %s') . '<br/>', $folder );
    129                                 $ret = $this->find_base_dir( $folder, $echo);
     129                                $ret = $this->find_base_dir( $folder, $echo, $loop);
    130130                                if( $ret )
    131131                                        return $ret;
    132132                        }
     
    136136                        if($echo) printf( __('Found %s'),  $base . 'wp-settings.php<br/>' );
    137137                        return $base;
    138138                }
    139                 return false;
     139                if( $loop )
     140                        return false;//Prevent tihs function looping again.
     141                //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
     142                return $this->find_base_dir('/', $echo, true);
    140143        }
    141144
    142145        function get_base_dir($base = '.', $echo = false){
  • wp-admin/includes/class-wp-filesystem-ftpsockets.php

     
    8686                $this->permission = $perm;
    8787        }
    8888
    89         function find_base_dir($base = '.',$echo = false) {
     89        function find_base_dir($base = '.',$echo = false, $loop = false) {
    9090                //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
    9191                $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
    9292                if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
     
    100100
    101101                //Can we see the Current directory as part of the ABSPATH?
    102102                $location = strpos($abspath, $base);
    103                 if( false !== $location ){
     103                if( false !== $location ) {
    104104                        $newbase = path_join($base, substr($abspath, $location + strlen($base)));
    105105
    106106                        if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly.
     
    128128                                //Lets try that folder:
    129129                                $folder = path_join($base, $key);
    130130                                if($echo) printf( __('Changing to %s') . '<br/>', $folder );
    131                                 $ret = $this->find_base_dir( $folder, $echo);
     131                                $ret = $this->find_base_dir( $folder, $echo, $loop);
    132132                                if( $ret )
    133133                                        return $ret;
    134134                        }
     
    138138                        if($echo) printf( __('Found %s'),  $base . 'wp-settings.php<br/>' );
    139139                        return $base;
    140140                }
    141                 return false;
     141                if( $loop )
     142                        return false;//Prevent tihs function looping again.
     143                //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
     144                return $this->find_base_dir('/', $echo, true);
    142145        }
    143146
    144147        function get_base_dir($base = '.', $echo = false){