Media: Reverts `get_attached_file()` changes for normalized Windows paths.

Based on feedback from network storage configurations there was a noticed slowdown due to the usage of the `path_join()` function. This needs more time to find a workaround.

Follow-up to [53934].
Props mreishus, SergeyBiryukov, desrosj, mikeschroder.
Reverts [53934].
See #56924.

Built from https://develop.svn.wordpress.org/trunk@54712


git-svn-id: http://core.svn.wordpress.org/trunk@54264 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
antpb 2022-10-28 15:18:11 +00:00
parent 322445185a
commit 1d4fa825b8
3 changed files with 3 additions and 10 deletions

View File

@ -2079,7 +2079,6 @@ function wp_mkdir_p( $target ) {
* For example, '/foo/bar', or 'c:\windows'. * For example, '/foo/bar', or 'c:\windows'.
* *
* @since 2.5.0 * @since 2.5.0
* @since 6.1.0 Allows normalized Windows paths (forward slashes).
* *
* @param string $path File path. * @param string $path File path.
* @return bool True if path is absolute, false is not absolute. * @return bool True if path is absolute, false is not absolute.
@ -2110,11 +2109,6 @@ function path_is_absolute( $path ) {
return true; return true;
} }
// Normalized Windows paths for local filesystem and network shares (forward slashes).
if ( preg_match( '#(^[a-zA-Z]+:/|^//[\w!@\#\$%\^\(\)\-\'{}\.~]{1,15})#', $path ) ) {
return true;
}
// A path starting with / or \ is absolute; anything else is relative. // A path starting with / or \ is absolute; anything else is relative.
return ( '/' === $path[0] || '\\' === $path[0] ); return ( '/' === $path[0] || '\\' === $path[0] );
} }

View File

@ -724,11 +724,10 @@ function get_attached_file( $attachment_id, $unfiltered = false ) {
$file = get_post_meta( $attachment_id, '_wp_attached_file', true ); $file = get_post_meta( $attachment_id, '_wp_attached_file', true );
// If the file is relative, prepend upload dir. // If the file is relative, prepend upload dir.
if ( $file ) { if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ) {
$uploads = wp_get_upload_dir(); $uploads = wp_get_upload_dir();
if ( false === $uploads['error'] ) { if ( false === $uploads['error'] ) {
$file = path_join( $uploads['basedir'], $file ); $file = $uploads['basedir'] . "/$file";
} }
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.2-alpha-54711'; $wp_version = '6.2-alpha-54712';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.