WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#35375 new defect (bug)

function wp_guess_url not compatible with symlinks

Reported by: jorgeorpinel Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Upgrade/Install Keywords:
Focuses: Cc:
PR Number:

Description (last modified by SergeyBiryukov)

If your web root is a symlink to another directory in the server, common for continuous delivery environments, wp_guess_url will try to find

  $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] );

inside of

  $abspath_fix = str_replace( '\\', '/', ABSPATH );

in line 3837 of wp-includes/functions.php :

                        } elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) {

Since $_SERVER['SCRIPT_FILENAME'] will resolve a symlink these 2 will be completely different and the elseif will be skipped, so $path = $_SERVER['REQUEST_URI'];

Is this a problem? Only if you have WordPress installed as a dependency with Composer. See https://github.com/johnpbloch/wordpress -- so maybe I shouold report the bug to his repo instead... Not sure!

Possible fix: I tried wrapping dirname() in readlink() but won't work when the path is not a symlink. Maybe a conditional check?

Change History (2)

#1 @SergeyBiryukov
4 months ago

  • Component changed from General to Upgrade/Install
  • Description modified (diff)

#2 @SergeyBiryukov
4 months ago

Related: #25797, #46136

Last edited 4 months ago by SergeyBiryukov (previous) (diff)
Note: See TracTickets for help on using tickets.