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.


git-svn-id: https://develop.svn.wordpress.org/trunk@44785 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Aaron Jorbin
2019-03-01 20:57:26 +00:00
parent 4c45ff7c43
commit e421f262dc
32 changed files with 101 additions and 101 deletions

View File

@@ -29,7 +29,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
function test_resize_jpg() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 );
$this->assertEquals( 'test-image-25x25.jpg', basename( $image ) );
$this->assertEquals( 'test-image-25x25.jpg', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 25, $w );
$this->assertEquals( 25, $h );
@@ -45,7 +45,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
$this->fail( sprintf( 'No PNG support in the editor engine %s on this system', $this->editor_engine ) );
}
$this->assertEquals( 'test-image-25x25.png', basename( $image ) );
$this->assertEquals( 'test-image-25x25.png', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 25, $w );
$this->assertEquals( 25, $h );
@@ -61,7 +61,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
$this->fail( sprintf( 'No GIF support in the editor engine %s on this system', $this->editor_engine ) );
}
$this->assertEquals( 'test-image-25x25.gif', basename( $image ) );
$this->assertEquals( 'test-image-25x25.gif', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 25, $w );
$this->assertEquals( 25, $h );
@@ -81,7 +81,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
function test_resize_thumb_128x96() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 );
$this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', basename( $image ) );
$this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 64, $w );
$this->assertEquals( 96, $h );
@@ -93,7 +93,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
function test_resize_thumb_128x0() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 );
$this->assertEquals( '2007-06-17DSC_4173-128x193.jpg', basename( $image ) );
$this->assertEquals( '2007-06-17DSC_4173-128x193.jpg', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 128, $w );
$this->assertEquals( 193, $h );
@@ -105,7 +105,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
function test_resize_thumb_0x96() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 );
$this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', basename( $image ) );
$this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 64, $w );
$this->assertEquals( 96, $h );
@@ -117,7 +117,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
function test_resize_thumb_150x150_crop() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true );
$this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', basename( $image ) );
$this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 150, $w );
$this->assertEquals( 150, $h );
@@ -129,7 +129,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
function test_resize_thumb_150x100_crop() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 100, true );
$this->assertEquals( '2007-06-17DSC_4173-150x100.jpg', basename( $image ) );
$this->assertEquals( '2007-06-17DSC_4173-150x100.jpg', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 150, $w );
$this->assertEquals( 100, $h );
@@ -141,7 +141,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
function test_resize_thumb_50x150_crop() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true );
$this->assertEquals( '2007-06-17DSC_4173-50x150.jpg', basename( $image ) );
$this->assertEquals( '2007-06-17DSC_4173-50x150.jpg', wp_basename( $image ) );
list($w, $h, $type) = getimagesize( $image );
$this->assertEquals( 50, $w );
$this->assertEquals( 150, $h );