Make WordPress Core


Ignore:
Timestamp:
03/01/2019 08:57:26 PM (5 years 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/resize.php

    r42343 r44785  
    3030        $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 );
    3131
    32         $this->assertEquals( 'test-image-25x25.jpg', basename( $image ) );
     32        $this->assertEquals( 'test-image-25x25.jpg', wp_basename( $image ) );
    3333        list($w, $h, $type) = getimagesize( $image );
    3434        $this->assertEquals( 25, $w );
     
    4646        }
    4747
    48         $this->assertEquals( 'test-image-25x25.png', basename( $image ) );
     48        $this->assertEquals( 'test-image-25x25.png', wp_basename( $image ) );
    4949        list($w, $h, $type) = getimagesize( $image );
    5050        $this->assertEquals( 25, $w );
     
    6262        }
    6363
    64         $this->assertEquals( 'test-image-25x25.gif', basename( $image ) );
     64        $this->assertEquals( 'test-image-25x25.gif', wp_basename( $image ) );
    6565        list($w, $h, $type) = getimagesize( $image );
    6666        $this->assertEquals( 25, $w );
     
    8282        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 );
    8383
    84         $this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', basename( $image ) );
     84        $this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) );
    8585        list($w, $h, $type) = getimagesize( $image );
    8686        $this->assertEquals( 64, $w );
     
    9494        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 );
    9595
    96         $this->assertEquals( '2007-06-17DSC_4173-128x193.jpg', basename( $image ) );
     96        $this->assertEquals( '2007-06-17DSC_4173-128x193.jpg', wp_basename( $image ) );
    9797        list($w, $h, $type) = getimagesize( $image );
    9898        $this->assertEquals( 128, $w );
     
    106106        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 );
    107107
    108         $this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', basename( $image ) );
     108        $this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) );
    109109        list($w, $h, $type) = getimagesize( $image );
    110110        $this->assertEquals( 64, $w );
     
    118118        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true );
    119119
    120         $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', basename( $image ) );
     120        $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', wp_basename( $image ) );
    121121        list($w, $h, $type) = getimagesize( $image );
    122122        $this->assertEquals( 150, $w );
     
    130130        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 100, true );
    131131
    132         $this->assertEquals( '2007-06-17DSC_4173-150x100.jpg', basename( $image ) );
     132        $this->assertEquals( '2007-06-17DSC_4173-150x100.jpg', wp_basename( $image ) );
    133133        list($w, $h, $type) = getimagesize( $image );
    134134        $this->assertEquals( 150, $w );
     
    142142        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true );
    143143
    144         $this->assertEquals( '2007-06-17DSC_4173-50x150.jpg', basename( $image ) );
     144        $this->assertEquals( '2007-06-17DSC_4173-50x150.jpg', wp_basename( $image ) );
    145145        list($w, $h, $type) = getimagesize( $image );
    146146        $this->assertEquals( 50, $w );
Note: See TracChangeset for help on using the changeset viewer.