[wp-trac] [WordPress Trac] #20934: class-wp-filesystem-base::search_for_folder returns incorrect path

WordPress Trac wp-trac at lists.automattic.com
Thu Jun 14 06:31:02 UTC 2012


#20934: class-wp-filesystem-base::search_for_folder returns incorrect path
--------------------------+------------------------------
 Reporter:  cgastrell     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Filesystem    |     Version:  3.3.2
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |
--------------------------+------------------------------

Comment (by cgastrell):

 I don't know how to graphically explain this, I just know it's wrong :)

 Take the array from the attached image, my working path:
  * [0] => 'var',
  * [1] => 'www',
  * [2] => 'domain.com.ar',
  * [3] => 'test'

 Then the ''foreach'' loop takes every item in the array and tries to
 '''guess''' the actual path, with a trial and error check with ''exists''
 for the path. The thing is that, for every item in the array, the loop
 tries to build the path from scratch.
 So, in the first run, the loop looks for the '''var''' directory from
 root. Fine, finds it and stablishes it as a starting point for the next
 loop.
  / + var::
    exists => stablish new starting path: /var
 Second and third item goes fine, as path ''exists'' and is correct path
 guessing.
  /var + /var::
    exists = false, next
  /var + /www::
    exists = true, stablish starting path, next loop
 Third run:
  /var/www + /var::
    exists = false, next
  /var/www + /www::
    exists = false, next
  /var/www + /domain.com.ar::
    exists = true, stablish starting path, next loop

 As the fourth run occurs, the issue arises:
  /var/www/domain.com.ar + /var::
    exists = false, next
  /var/www/domain.com.ar + /www::
    exists = true, but the path found here is only found by mere
 coincidence of using a directory with a same name twice. My installation
 was at ''/var/www/domain.com.ar/test'' but it happens that I had my
 original installation at ''/var/www/domain.com.ar/www'' as the working
 live site, so it finds it but is wrongly guessed.

 This is something not carefully thought, and I say this without any
 offensive intention, you just don't go around ''guessing'' paths like
 this. I know my case is quite rare because of the way I arrange my
 directories, but this could have lead to a catastrophic scenario in a
 shared hosting. Mine es merely a multiple vhosted apache.

 Hope this helps understanding the issue.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20934#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list