[wp-trac] [WordPress Trac] #20449: get_home_path() error on windows with different home and site_url values
WordPress Trac
wp-trac at lists.automattic.com
Sun Apr 15 20:39:55 UTC 2012
#20449: get_home_path() error on windows with different home and site_url values
--------------------------+-----------------------------
Reporter: iturgeon | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version: 3.3.1
Severity: normal | Keywords:
--------------------------+-----------------------------
get_home_path() was always returning a root directory reference '/'
= Environment: =
IIS 7.5, FCGI, PHP 5.3.10, WP 3.3.1
== Walking through ==
I'll just run through what's happening to the values below:
{{{
// for ref, script_filename is
//$_SERVER["SCRIPT_FILENAME"] = 'D:\root\vhosts\site\httpdocs\wp\wp-admin
\options-permalink.php'
function get_home_path() {
$home = get_option( 'home' );
// $home='http://site.com'
$siteurl = get_option( 'siteurl' );
// $siteurl = 'http://site.com/wp'
if ( $home != '' && $home != $siteurl ) {
$wp_path_rel_to_home = str_replace($home, '', $siteurl);
// $wp_path_rel_to_home = '/wp'
$pos = strpos($_SERVER["SCRIPT_FILENAME"],
$wp_path_rel_to_home);
// $pos = FALSE
$home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
// $home_path = ''
$home_path = trailingslashit( $home_path );
// $home_path = '/'
} else {
$home_path = ABSPATH;
}
return $home_path;
// returns '/'
}
}}}
Suggest adding the following line
{{{
$wp_path_rel_to_home = str_replace('/', DIRECTORY_SEPARATOR,
$wp_path_rel_to_home);
}}}
Diff:
{{{
--- a/wp/wp-admin/includes/file.php
+++ b/wp/wp-admin/includes/file.php
@@ -81,6 +81,7 @@ function get_home_path() {
$siteurl = get_option( 'siteurl' );
if ( $home != '' && $home != $siteurl ) {
$wp_path_rel_to_home = str_replace($home, '', $siteurl);
/* $siteurl - $home */
+ $wp_path_rel_to_home = str_replace('/',
DIRECTORY_SEPARATOR, $wp_path_rel_to_home); // replaces url slashs with
backslashes when needed
$pos = strpos($_SERVER["SCRIPT_FILENAME"],
$wp_path_rel_to_home);
$home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
$home_path = trailingslashit( $home_path );
--
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20449>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list