Skip to content

Commit

Permalink
Media: Reverts get_attached_file() changes for normalized Windows p…
Browse files Browse the repository at this point in the history
…aths.

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
  • Loading branch information
antpb committed Oct 28, 2022
1 parent 3224451 commit 1d4fa82
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
6 changes: 0 additions & 6 deletions wp-includes/functions.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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] );
}
Expand Down
5 changes: 2 additions & 3 deletions wp-includes/post.php
Expand Up @@ -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";
}
}

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -16,7 +16,7 @@
*
* @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.
Expand Down

0 comments on commit 1d4fa82

Please sign in to comment.