Make WordPress Core

Changeset 25024


Ignore:
Timestamp:
08/15/2013 05:59:36 AM (13 years ago)
Author:
dd32
Message:

WP_Filesystem: Make WP_Filesystem_Base::search_for_folder() a bit more usable on the command-line when the $verbose mode is used, additionally, bail early from the function rather than repeating itself if the CWD is the root directory already.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-base.php

    r23349 r25024  
    193193                $folder = untrailingslashit($folder);
    194194
     195                if ( $this->verbose )
     196                        printf( "\n" . __('Looking for %1$s in %2$s') . "<br/>\n", $folder, $base );
     197
    195198                $folder_parts = explode('/', $folder);
    196                 $last_index = array_pop( array_keys( $folder_parts ) );
     199                $folder_part_keys = array_keys( $folder_parts );
     200                $last_index = array_pop( $folder_part_keys );
    197201                $last_path = $folder_parts[ $last_index ];
    198202
    … …  
    211215                                $newdir = trailingslashit(path_join($base, $key));
    212216                                if ( $this->verbose )
    213                                         printf( __('Changing to %s') . '<br/>', $newdir );
     217                                        printf( "\n" . __('Changing to %s') . "<br/>\n", $newdir );
    214218                                // only search for the remaining path tokens in the directory, not the full path again
    215219                                $newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
    … …  
    222226                if (isset( $files[ $last_path ] ) ) {
    223227                        if ( $this->verbose )
    224                                 printf( __('Found %s') . '<br/>',  $base . $last_path );
     228                                printf( "\n" . __('Found %s') . "<br/>\n",  $base . $last_path );
    225229                        return trailingslashit($base . $last_path);
    226230                }
    227                 if ( $loop )
    228                         return false; //Prevent this function from looping again.
    229                 //As an extra last resort, Change back to / if the folder wasn't found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
    230                 return $this->search_for_folder($folder, '/', true);
     231
     232                // Prevent this function from looping again.
     233                // No need to proceed if we've just searched in /
     234                if ( $loop || '/' == $base )
     235                        return false;
     236
     237                // As an extra last resort, Change back to / if the folder wasn't found.
     238                // This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
     239                return $this->search_for_folder( $folder, '/', true );
    231240
    232241        }
Note: See TracChangeset for help on using the changeset viewer.