#48075 closed task (blessed) (fixed)
Remove conditional use of PHP realpath()
Reported by: | jrf | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | 5.3 |
Component: | General | Keywords: | has-patch |
Focuses: | performance, coding-standards | Cc: |
Description
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 if ( function_exists( 'realpath' ) ) { $path = realpath( $path ); }
Now, there are only two reasons I can think for this code to exist:
- Support for PHP < 4.
The `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.
- Hosts disabling the function using the `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).
Kindly ignore my last patch.