Make WordPress Core

Ticket #44563: wordpress-4.9.7-delete-media-streamwrapper.patch

File wordpress-4.9.7-delete-media-streamwrapper.patch, 1.5 KB (added by antonypuckey, 7 years ago)

Patch to allow stream wrapper urls to be deleted.

  • wp-includes/functions.php

    diff --git a/wp-includes/functions.php b/wp-includes/functions.php
    index 5802a34146..626d59f455 100644
    a b function wp_mkdir_p( $target ) { 
    16561656 * @return bool True if path is absolute, false is not absolute.
    16571657 */
    16581658function path_is_absolute( $path ) {
     1659        /*
     1660         * Check to see if the path is a stream and check to see if its an actual
     1661         * path or file as realpath() does not support streamwrappers.
     1662         */
     1663        if (wp_is_stream($path) && (is_dir($path) || is_file($path))) {
     1664                return true;
     1665        }
     1666
    16591667        /*
    16601668         * This is definitive if true but fails if $path does not exist or contains
    16611669         * a symbolic link.
    function wp_delete_file( $file ) { 
    55265534 * @return bool True on success, false on failure.
    55275535 */
    55285536function wp_delete_file_from_directory( $file, $directory ) {
    5529         $real_file = realpath( wp_normalize_path( $file ) );
    5530         $real_directory = realpath( wp_normalize_path( $directory ) );
     5537        if ( wp_is_stream($file) ) {
     5538                $real_file = wp_normalize_path($file);
     5539                $real_directory = wp_normalize_path($directory);
     5540        } else {
     5541                $real_file = realpath( wp_normalize_path($file) );
     5542                $real_directory = realpath ( wp_normalize_path($directory) );
     5543        }
    55315544
    5532         if ( false === $real_file || false === $real_directory || strpos( wp_normalize_path( $real_file ), trailingslashit( wp_normalize_path( $real_directory ) ) ) !== 0 ) {
     5545        if ( false === $real_file || false === $real_directory || strpos( $real_file, trailingslashit( $real_directory ) ) !== 0 ) {
    55335546                return false;
    55345547        }
    55355548