Make WordPress Core

Changeset 45352


Ignore:
Timestamp:
05/17/2019 01:28:15 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Media: Fix deletion of files on Windows.

wp_delete_file_from_directory() should always normalize file paths before comparing.

Props tonybogdanov, SergeyBiryukov.
Fixes #47185.

File:
1 edited

Legend:

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

    r45249 r45352  
    62836283function wp_delete_file_from_directory( $file, $directory ) {
    62846284    if ( wp_is_stream( $file ) ) {
    6285         $real_file      = wp_normalize_path( $file );
    6286         $real_directory = wp_normalize_path( $directory );
     6285        $real_file      = $file;
     6286        $real_directory = $directory;
    62876287    } else {
    62886288        $real_file      = realpath( wp_normalize_path( $file ) );
    62896289        $real_directory = realpath( wp_normalize_path( $directory ) );
     6290    }
     6291
     6292    if ( false !== $real_file ) {
     6293        $real_file = wp_normalize_path( $real_file );
     6294    }
     6295
     6296    if ( false !== $real_directory ) {
     6297        $real_directory = wp_normalize_path( $real_directory );
    62906298    }
    62916299
Note: See TracChangeset for help on using the changeset viewer.