From fb2e1cfc1f3fa797407a56cf4f209302c3398397 Mon Sep 17 00:00:00 2001 From: antpb Date: Fri, 28 Oct 2022 15:30:15 +0000 Subject: [PATCH] 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] in the 6.1 Branch. See #56924. Built from https://develop.svn.wordpress.org/branches/6.1@54713 git-svn-id: http://core.svn.wordpress.org/branches/6.1@54265 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 6 ------ wp-includes/post.php | 5 ++--- wp-includes/version.php | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index c303f0d4a6..563c4d78b8 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2079,7 +2079,6 @@ function wp_mkdir_p( $target ) { * For example, '/foo/bar', or 'c:\windows'. * * @since 2.5.0 - * @since 6.1.0 Allows normalized Windows paths (forward slashes). * * @param string $path File path. * @return bool True if path is absolute, false is not absolute. @@ -2110,11 +2109,6 @@ function path_is_absolute( $path ) { 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. return ( '/' === $path[0] || '\\' === $path[0] ); } diff --git a/wp-includes/post.php b/wp-includes/post.php index a67d7a79a1..d7e7bfec99 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -724,11 +724,10 @@ function get_attached_file( $attachment_id, $unfiltered = false ) { $file = get_post_meta( $attachment_id, '_wp_attached_file', true ); // If the file is relative, prepend upload dir. - if ( $file ) { + if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ) { $uploads = wp_get_upload_dir(); - if ( false === $uploads['error'] ) { - $file = path_join( $uploads['basedir'], $file ); + $file = $uploads['basedir'] . "/$file"; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 54acffcf04..076c45a28d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-RC4-54709'; +$wp_version = '6.1-RC4-54713'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.