[wp-trac] [WordPress Trac] #36308: get_attached_file() destroys file paths on Windows
WordPress Trac
noreply at wordpress.org
Mon Oct 23 10:07:22 UTC 2017
#36308: get_attached_file() destroys file paths on Windows
-------------------------------------------------+-------------------------
Reporter: Whissi | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
Component: Media | Review
Severity: normal | Version: 4.4.2
Keywords: needs-unit-tests good-first-bug | Resolution:
has-patch | Focuses:
-------------------------------------------------+-------------------------
Comment (by birgire):
There is actually a core function called {{{path_is_absolute()}}}:
https://developer.wordpress.org/reference/functions/path_is_absolute/
so I wonder why it isn't used in {{{get_attached_file()}}}, like:
{{{
if ( ! path_is_absolute( $file ) && ( ($uploads = wp_upload_dir()) &&
false === $uploads['error'] ) )
$file = $uploads['basedir'] . "/$file";
}}}
In that case {{{path_is_absolute()}}} could be further updated to handle
url or normalized paths.
There's also the {{{path_join()}}}:
https://developer.wordpress.org/reference/functions/path_join/
that uses {{{path_is_absolute()}}} internally. This is e.g. used in
{{{_wp_upload_dir()}}}.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36308#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list