Make WordPress Core

Opened 2 years ago

Last modified 14 months ago

#52575 new defect (bug)

get_home_path() returns "/" instead of path to WordPress directory

Reported by: pixellogik's profile pixellogik Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 5.6.1
Component: Filesystem API Keywords: reporter-feedback dev-feedback close
Focuses: Cc:


Wrong return value from get_home_path() in /wp-admin/includes/file.php

Expected result: Absolute filesystem path to the root of the WordPress installation
Result in situation below: /

A WordPress in its own directory installed according method II mentioned here

Settings (Example)

Plugin WP-SCSS installed

Open in a browser

The plugin calls get_home_path() in enqueue_files() in line 213

Due to the unexpected value "/" of get_home_path() the URL of the generated CSS file does not point to a file.
The CSS won't be loaded, the site looks scrambled.

What went wrong?
If SCRIPT_FILENAME is outside the installation directory, the directory can't be found. This case is not handled, hence value "/" is returned

Possible fix:
return ABSPATH in that case

Change History (2)

#1 @costdev
21 months ago

  • Keywords reporter-feedback dev-feedback close added

I just followed Method II here as the ticket mentions. My custom scss is compiled and correctly loaded into the theme.


  1. I used pretty permalinks i.e. /%postname%/, which meant copying the .htaccess file from wp/ back to the root directory as stated in the guide linked above. I also had to refresh permalinks in the admin.
  2. Once this is done, I had to go to the WP SCSS settings and click Save Settings, which correctly pointed the plugin to the new location for the files.

There don't seem to be any commits to this function since the ticket was raised. It's possible that one of the steps above or in the guide were missed.

Pending reporter feedback, or dev feedback regarding whether or not there is a sufficient number of edge cases to suggest that get_home_path() should handle when SCRIPT_FILENAME is outside the installation directory, I think this ticket is ready to close.

#2 @lllor
14 months ago

I confirm the issue.

In short, when accessing the website using the index.php in the root folder (it happens only when visiting the homepage) the


is loaded with the root folderpath and the subsequent string processing performed by get_home_page is not executed correctly. As a workaround, the .htaccess should redirect even the / url to the subdirectory/index.php

Note: See TracTickets for help on using tickets.