﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
20449	get_home_path() error on windows with different home and site_url values	iturgeon	dd32	"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 );
-- 
}}}"	defect (bug)	closed	normal	3.5	Permalinks	3.3.1	normal	fixed	has-patch commit	knut@…
