[wp-trac] [WordPress Trac] #48075: Remove conditional use of PHP realpath()
WordPress Trac
noreply at wordpress.org
Thu Sep 19 17:05:30 UTC 2019
#48075: Remove conditional use of PHP realpath()
-------------------------------------------+-----------------------------
Reporter: jrf | Owner: SergeyBiryukov
Type: task (blessed) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords: has-patch
Focuses: performance, coding-standards |
-------------------------------------------+-----------------------------
While working on #48074 / looking for code which can be removed now
support for PHP < 5.6.20 has been dropped, I came across two instances of
conditional use of the `realpath()` function.
{{{#!php
<?php
if ( function_exists( 'realpath' ) ) {
$path = realpath( $path );
}
}}}
Now, there are only two reasons I can think for this code to exist:
1. Support for PHP < 4.
The [https://www.php.net/manual/en/function.realpath.php `realpath()`
function] was introduced in PHP 4.0.0. It might be that this code is so
ancient that it is from before that time.
I've tried to trace this back, but got stuck somewhere in 2009.
2. Hosts disabling the function using the
[https://www.php.net/manual/en/ini.core.php#ini.disable-functions
`disabled_functions` ini directive].
I honestly don't know if that's a thing and it would be pretty foolish (of
hosts) if they did, but that's the only other reason I could think of for
this code to exist.
It would be great if someone with a long memory could chime in here.
If the reason is **1)**, the removal of these conditions is long overdue.
If the reason is **2)**, based on a quick scan, there are 27 more
instances within WP where `realpath()` is used ''without'' a
`function_exists()` check.
I'm presuming, for now, that the reason is 1) and am attaching a patch to
''remove'' the condition.
If by some happenstance, the reason for this code would turn out to be 2),
a new patch would need to be created to ''add'' the condition to the other
27 instance of `realpath()` in core (or better yet a `wp_realpath()`
function or similar should be added instead).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48075>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list