WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/01/2019 08:57:26 PM (6 months ago)
Author:
jorbin
Message:

Replace usages of basename() with wp_basename() in order to support multibyte filenames

This is focused on the pieces of code that touch media files and the tests that support them. basename isn't multibyte compatible out of the box. See http://php.net/basename and https://bugs.php.net/bug.php?id=62119.

See #43170.
Props Viper007Bond.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/siteIcon.php

    r42343 r44785  
    102102        $attachment_id = $this->_insert_attachment();
    103103        $parent_url    = get_post( $attachment_id )->guid;
    104         $cropped       = str_replace( basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
     104        $cropped       = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
    105105
    106106        $object = $this->wp_site_icon->create_attachment_object( $cropped, $attachment_id );
     
    116116        $attachment_id = $this->_insert_attachment();
    117117        $parent_url    = get_post( $attachment_id )->guid;
    118         $cropped       = str_replace( basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
     118        $cropped       = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
    119119
    120120        $object     = $this->wp_site_icon->create_attachment_object( $cropped, $attachment_id );
     
    164164        $contents = file_get_contents( $filename );
    165165
    166         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     166        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    167167
    168168        $this->attachment_id = $this->_make_attachment( $upload );
Note: See TracChangeset for help on using the changeset viewer.