[wp-trac] [WordPress Trac] #35375: function wp_guess_url not compatible with symlinks
WordPress Trac
noreply at wordpress.org
Sat Jul 27 01:11:04 UTC 2019
#35375: function wp_guess_url not compatible with symlinks
-----------------------------+---------------------
Reporter: jorgeorpinel | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone:
Component: Upgrade/Install | Version: 4.3
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+---------------------
Changes (by SergeyBiryukov):
* component: General => Upgrade/Install
Old description:
> 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
> {{{#!php
> $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] );
> }}}
> inside of
> {{{#!php
> $abspath_fix = str_replace( '\\', '/', ABSPATH );
> }}}
> in line 3837 of wp-includes/functions.php :
> {{{#!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?
New description:
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
{{{#!php
$script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] );
}}}
inside of
{{{#!php
$abspath_fix = str_replace( '\\', '/', ABSPATH );
}}}
in line 3837 of wp-includes/functions.php :
{{{#!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?
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35375#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list