[wp-trac] [WordPress Trac] #18768: WordPress may not return correct $home_path when installed in a subdirectory

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 24 21:52:37 UTC 2011


#18768: WordPress may not return correct $home_path when installed in a
subdirectory
--------------------------+-----------------------------
 Reporter:  ptahdunbar    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.3
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 I've got a local install of WordPress set within a subdirectory of the
 root (like all the cool kids).

 Here's the file path:
 `/Users/ptah/Sites/vhosts/wp.dev/www/wp/`

 After installing and setting pretty permalinks, WordPress wasn't able to
 create the .htaccess file even though it had write access to the root
 folder.

 I traced the bug down to `get_home_path()` where it trys to guess the
 WordPress directory by `strpos()` the script path against the relative wp
 path. Starting the comparison from left to right, it stopped at the first
 wp it found giving me the following home path:
 `/Users/ptah/Sites/vhosts/`

 Well, that's wrong. It should be:
 `/Users/ptah/Sites/vhosts/wp.dev/www/wp/`

 Patch fixes this by using `strrpos()` instead which stops at the last
 occurrence of the needle.
 Given that it's matching against `$_SERVER['SCRIPT_FILENAME']`, it's more
 logical to work from the script path of WordPress than the other way
 around which may or may not contain duplicate matches.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18768>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list