Skip to content

Commit d4ba9cd

Browse files
committed
Use SCRIPT_FILENAME instead of PATH_TRANSLATED since PATH_TRANSLATED is not always set. Consolidate home path logic into get_home_path().
git-svn-id: https://develop.svn.wordpress.org/trunk@1995 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 978063c commit d4ba9cd

2 files changed

Lines changed: 19 additions & 28 deletions

File tree

wp-admin/admin-functions.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,7 @@ function extract_from_markers($filename, $marker) {
495495

496496
function save_mod_rewrite_rules() {
497497
global $is_apache, $wp_rewrite;
498-
$home = get_settings('home');
499-
if ( $home != '' && $home != get_settings('siteurl') ) {
500-
$home_path = parse_url($home);
501-
$home_path = $home_root['path'];
502-
$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
503-
$home_path = $root . $home_path . "/";
504-
} else {
505-
$home_path = ABSPATH;
506-
}
498+
$home_path = get_home_path();
507499

508500
if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
509501
$writable = true;
@@ -787,17 +779,24 @@ function validate_file_to_edit($file, $allowed_files = '') {
787779
return $file;
788780
}
789781

790-
function get_real_file_to_edit($file) {
782+
function get_home_path() {
791783
$home = get_settings('home');
792-
if (($home != '')
793-
&& ($home != get_settings('siteurl')) &&
794-
('index.php' == $file || get_settings('blogfilename') == $file ||
795-
'.htaccess' == $file)) {
796-
$home_root = parse_url($home);
797-
$home_root = $home_root['path'];
798-
$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
799-
$home_root = $root . $home_root;
800-
$real_file = $home_root . '/' . $file;
784+
if ( $home != '' && $home != get_settings('siteurl') ) {
785+
$home_path = parse_url($home);
786+
$home_path = $home_root['path'];
787+
$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"]);
788+
$home_path = $root . $home_path . "/";
789+
} else {
790+
$home_path = ABSPATH;
791+
}
792+
793+
return $home_path;
794+
}
795+
796+
function get_real_file_to_edit($file) {
797+
if ('index.php' == $file || get_settings('blogfilename') == $file ||
798+
'.htaccess' == $file) {
799+
$real_file = get_home_path() . $file;
801800
} else {
802801
$real_file = ABSPATH . $file;
803802
}

wp-admin/options-permalink.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@
66

77
include('admin-header.php');
88

9-
$home = get_settings('home');
10-
if ( $home != '' && $home != get_settings('siteurl') ) {
11-
$home_path = parse_url($home);
12-
$home_path = $home_root['path'];
13-
$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
14-
$home_path = $root . $home_path . "/";
15-
} else {
16-
$home_path = ABSPATH;
17-
}
9+
$home_path = get_home_path();
1810

1911
if ( isset($_POST) ) {
2012
if ( isset($_POST['permalink_structure']) ) {

0 commit comments

Comments
 (0)