Make WordPress Core

Changeset 54713


Ignore:
Timestamp:
10/28/2022 03:28:59 PM (2 years ago)
Author:
antpb
Message:

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.

Location:
branches/6.1
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1/src/wp-includes/functions.php

    r54522 r54713  
    20802080 *
    20812081 * @since 2.5.0
    2082  * @since 6.1.0 Allows normalized Windows paths (forward slashes).
    20832082 *
    20842083 * @param string $path File path.
     
    21082107    // Windows allows absolute paths like this.
    21092108    if ( preg_match( '#^[a-zA-Z]:\\\\#', $path ) ) {
    2110         return true;
    2111     }
    2112 
    2113     // Normalized Windows paths for local filesystem and network shares (forward slashes).
    2114     if ( preg_match( '#(^[a-zA-Z]+:/|^//[\w!@\#\$%\^\(\)\-\'{}\.~]{1,15})#', $path ) ) {
    21152109        return true;
    21162110    }
  • branches/6.1/src/wp-includes/post.php

    r54524 r54713  
    725725
    726726    // If the file is relative, prepend upload dir.
    727     if ( $file ) {
     727    if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ) {
    728728        $uploads = wp_get_upload_dir();
    729 
    730729        if ( false === $uploads['error'] ) {
    731             $file = path_join( $uploads['basedir'], $file );
     730            $file = $uploads['basedir'] . "/$file";
    732731        }
    733732    }
  • branches/6.1/tests/phpunit/tests/functions.php

    r54509 r54713  
    106106            'C:\\WINDOWS',
    107107            '\\\\sambashare\\foo',
    108             'c:/',
    109             'c://',
    110             '//',
    111             'c:/FOO',
    112             '//FOO',
    113             'C:/WWW/Sites/demo/htdocs/wordpress/wp-content/uploads/2016/03/example.jpg',
    114             '//ComputerName/ShareName/SubfolderName/example.txt',
    115108        );
    116109        foreach ( $absolute_paths as $path ) {
     
    127120            '../',
    128121            '../foo.bar',
    129             'foo.bar',
    130122            'foo/bar',
    131123            'foo',
    132124            'FOO',
    133125            '..\\WINDOWS',
    134             '..//WINDOWS',
    135             'c:',
    136             'C:',
    137126        );
    138127        foreach ( $relative_paths as $path ) {
Note: See TracChangeset for help on using the changeset viewer.