[wp-trac] [WordPress Trac] #9246: Wordpress cannot update '.htaccess' even though it is writable

WordPress Trac wp-trac at lists.automattic.com
Sat Feb 28 01:15:25 GMT 2009


#9246: Wordpress cannot update '.htaccess' even though it is writable
--------------------------+-------------------------------------------------
 Reporter:  akd907        |       Owner:  anonymous                        
     Type:  defect (bug)  |      Status:  new                              
 Priority:  normal        |   Milestone:  2.7.2                            
Component:  General       |     Version:  2.7.1                            
 Severity:  normal        |    Keywords:  htaccess, file.php, get_home_path
--------------------------+-------------------------------------------------
 I have attached a patch which fixes the problem. Here are some details:
 The culprit function was {{{get_home_path()}}} in file {{{wordpress/wp-
 admin/includes/file.php}}}. The path to {{{.htaccess}}} was turning out to
 be:
 {{{
 /u/akshay/public_html/wordpress/wp-admin/options-
 permalink.php/~akshay/.htaccess
 }}}
 when it actually should be:
 {{{
 /u/akshay/public_html/.htaccess
 }}}
 The reason was that this call was not returning the correct result:
 {{{
 $root = str_replace( $_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"]
 );
 }}}
 because {{{$_SERVER["PHP_SELF"]}}} had the value
 {{{
 /~akshay/wordpress/wp-admin/options-permalink.php
 }}}
 and {{{$_SERVER["SCRIPT_FILENAME"]}}} had the value
 {{{
 /u/akshay/public_html/wordpress/wp-admin/options-permalink.php
 }}}
 The main problem was that the path manipulation functions did not consider
 the presence of {{{/~username}}}. My blog URL is
 {{{http://web.cecs.pdx.edu/~akshay}}}, which is why the path in
 {{{PHP_SELF}}} was formed the way it was. I have attached a fix which I
 hope is generic enough to work. Let me know if it is not (in which case, I
 would need some hints on how to fix it). The patch is attached.

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


More information about the wp-trac mailing list