WordPress.org

Make WordPress Core

Changeset 44785


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

Location:
trunk
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/custom-background.php

    r44331 r44785  
    495495        $type     = $file['type'];
    496496        $file     = $file['file'];
    497         $filename = basename( $file );
     497        $filename = wp_basename( $file );
    498498
    499499        // Construct the object array
  • trunk/src/wp-admin/custom-header.php

    r44574 r44785  
    821821        } elseif ( $width > $max_width ) {
    822822            $oitar = $width / $max_width;
    823             $image = wp_crop_image( $attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace( basename( $file ), 'midsize-' . basename( $file ), $file ) );
     823            $image = wp_crop_image( $attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace( wp_basename( $file ), 'midsize-' . wp_basename( $file ), $file ) );
    824824            if ( ! $image || is_wp_error( $image ) ) {
    825825                wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) );
     
    829829            $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication
    830830
    831             $url    = str_replace( basename( $url ), basename( $image ), $url );
     831            $url    = str_replace( wp_basename( $url ), wp_basename( $image ), $url );
    832832            $width  = $width / $oitar;
    833833            $height = $height / $oitar;
     
    896896        $type     = $file['type'];
    897897        $file     = $file['file'];
    898         $filename = basename( $file );
     898        $filename = wp_basename( $file );
    899899
    900900        // Construct the object array
     
    985985
    986986        // Cleanup.
    987         $medium = str_replace( basename( $original ), 'midsize-' . basename( $original ), $original );
     987        $medium = str_replace( wp_basename( $original ), 'midsize-' . wp_basename( $original ), $original );
    988988        if ( file_exists( $medium ) ) {
    989989            wp_delete_file( $medium );
     
    12091209        $parent     = get_post( $parent_attachment_id );
    12101210        $parent_url = wp_get_attachment_url( $parent->ID );
    1211         $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
     1211        $url        = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
    12121212
    12131213        $size       = @getimagesize( $cropped );
     
    12161216        $object = array(
    12171217            'ID'             => $parent_attachment_id,
    1218             'post_title'     => basename( $cropped ),
     1218            'post_title'     => wp_basename( $cropped ),
    12191219            'post_mime_type' => $image_type,
    12201220            'guid'           => $url,
  • trunk/src/wp-admin/includes/ajax-actions.php

    r44777 r44785  
    36523652
    36533653            $parent_url = wp_get_attachment_url( $attachment_id );
    3654             $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
     3654            $url        = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
    36553655
    36563656            $size       = @getimagesize( $cropped );
     
    36583658
    36593659            $object = array(
    3660                 'post_title'     => basename( $cropped ),
     3660                'post_title'     => wp_basename( $cropped ),
    36613661                'post_content'   => $url,
    36623662                'post_mime_type' => $image_type,
  • trunk/src/wp-admin/includes/class-wp-site-icon.php

    r42871 r44785  
    8686        $parent     = get_post( $parent_attachment_id );
    8787        $parent_url = wp_get_attachment_url( $parent->ID );
    88         $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
     88        $url        = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
    8989
    9090        $size       = @getimagesize( $cropped );
     
    9393        $object = array(
    9494            'ID'             => $parent_attachment_id,
    95             'post_title'     => basename( $cropped ),
     95            'post_title'     => wp_basename( $cropped ),
    9696            'post_content'   => $url,
    9797            'post_mime_type' => $image_type,
  • trunk/src/wp-admin/includes/image-edit.php

    r43571 r44785  
    3434    $can_restore  = false;
    3535    if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
    36         $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] );
     36        $can_restore = $backup_sizes['full-orig']['file'] != wp_basename( $meta['file'] );
    3737    }
    3838
  • trunk/src/wp-admin/includes/image.php

    r44566 r44785  
    4848
    4949    if ( ! $dst_file ) {
    50         $dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file );
     50        $dst_file = str_replace( wp_basename( $src_file ), 'cropped-' . wp_basename( $src_file ), $src_file );
    5151    }
    5252
     
    5757    wp_mkdir_p( dirname( $dst_file ) );
    5858
    59     $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
     59    $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), wp_basename( $dst_file ) );
    6060
    6161    $result = $editor->save( $dst_file );
     
    190190                    break;
    191191            }
    192             $basename = str_replace( '.', '-', basename( $file ) ) . '-image' . $ext;
     192            $basename = str_replace( '.', '-', wp_basename( $file ) ) . '-image' . $ext;
    193193            $uploaded = wp_upload_bits( $basename, '', $metadata['image']['data'] );
    194194            if ( false === $uploaded['error'] ) {
     
    712712
    713713    if ( $src_file ) {
    714         $dst_file = str_replace( basename( $dst_file ), 'copy-' . basename( $dst_file ), $dst_file );
    715         $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
     714        $dst_file = str_replace( wp_basename( $dst_file ), 'copy-' . wp_basename( $dst_file ), $dst_file );
     715        $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), wp_basename( $dst_file ) );
    716716
    717717        /*
  • trunk/src/wp-admin/includes/import.php

    r44562 r44785  
    100100    // Construct the object array
    101101    $object = array(
    102         'post_title'     => basename( $upload['file'] ),
     102        'post_title'     => wp_basename( $upload['file'] ),
    103103        'post_content'   => $upload['url'],
    104104        'post_mime_type' => $upload['type'],
  • trunk/src/wp-admin/includes/media.php

    r44634 r44785  
    435435    $type    = $file['type'];
    436436    $file    = $file['file'];
    437     $title   = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
     437    $title   = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
    438438    $content = '';
    439439
     
    827827            $title = esc_html( wp_unslash( $_POST['title'] ) );
    828828            if ( empty( $title ) ) {
    829                 $title = esc_html( basename( $src ) );
     829                $title = esc_html( wp_basename( $src ) );
    830830            }
    831831
     
    931931
    932932        $file_array         = array();
    933         $file_array['name'] = basename( $matches[0] );
     933        $file_array['name'] = wp_basename( $matches[0] );
    934934
    935935        // Download file to temp location.
  • trunk/src/wp-admin/includes/misc.php

    r44779 r44785  
    363363                <?php
    364364                $file_description = esc_html( get_file_description( $filename ) );
    365                 if ( $file_description !== $filename && basename( $filename ) !== $file_description ) {
     365                if ( $file_description !== $filename && wp_basename( $filename ) !== $file_description ) {
    366366                    $file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
    367367                }
  • trunk/src/wp-content/themes/twentyten/loop-attachment.php

    r43571 r44785  
    139139                        </div><!-- #nav-below -->
    140140        <?php else : ?>
    141                         <a href="<?php echo esc_url( wp_get_attachment_url() ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php echo esc_html( basename( get_permalink() ) ); ?></a>
     141                        <a href="<?php echo esc_url( wp_get_attachment_url() ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php echo esc_html( wp_basename( get_permalink() ) ); ?></a>
    142142    <?php endif; ?>
    143143                        </div><!-- .entry-attachment -->
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r44714 r44785  
    13611361
    13621362                    // Copy file to temp location so that original file won't get deleted from theme after sideloading.
    1363                     $temp_file_name = wp_tempnam( basename( $file_path ) );
     1363                    $temp_file_name = wp_tempnam( wp_basename( $file_path ) );
    13641364                    if ( $temp_file_name && copy( $file_path, $temp_file_name ) ) {
    13651365                        $file_array['tmp_name'] = $temp_file_name;
     
    16221622                continue;
    16231623            }
    1624             $file_name = basename( $attachment['file'] );
     1624            $file_name = wp_basename( $attachment['file'] );
    16251625
    16261626            // Skip file types that are not recognized.
     
    45954595        if ( $this->return_url ) {
    45964596            $return_url = $this->return_url;
    4597         } elseif ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
     4597        } elseif ( $referer && ! in_array( wp_basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
    45984598            $return_url = $referer;
    45994599        } elseif ( $this->preview_url ) {
  • trunk/src/wp-includes/customize/class-wp-customize-media-control.php

    r42343 r44785  
    9393                    'type'  => $type,
    9494                    'icon'  => wp_mime_type_icon( $type ),
    95                     'title' => basename( $this->setting->default ),
     95                    'title' => wp_basename( $this->setting->default ),
    9696                );
    9797
  • trunk/src/wp-includes/deprecated.php

    r43174 r44785  
    18791879        // We have a thumbnail desired, specified and existing
    18801880
    1881         $src_file = basename($src);
     1881        $src_file = wp_basename($src);
    18821882    } elseif ( wp_attachment_is_image( $post->ID ) ) {
    18831883        // We have an image without a thumbnail
     
    18891889
    18901890        $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
    1891         $src_file = $icon_dir . '/' . basename($src);
     1891        $src_file = $icon_dir . '/' . wp_basename($src);
    18921892    }
    18931893
     
    30593059function get_theme_data( $theme_file ) {
    30603060    _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
    3061     $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
     3061    $theme = new WP_Theme( wp_basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
    30623062
    30633063    $theme_data = array(
  • trunk/src/wp-includes/functions.php

    r44690 r44785  
    20972097                    $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
    20982098                } else {
    2099                     $error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
     2099                    $error_path = wp_basename( $uploads['basedir'] ) . $uploads['subdir'];
    21002100                }
    21012101
     
    23822382            $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
    23832383        } else {
    2384             $error_path = basename( $upload['basedir'] ) . $upload['subdir'];
     2384            $error_path = wp_basename( $upload['basedir'] ) . $upload['subdir'];
    23852385        }
    23862386
  • trunk/src/wp-includes/media.php

    r44566 r44785  
    28722872
    28732873    $file     = get_attached_file( $attachment->ID );
    2874     $filename = basename( $file );
     2874    $filename = wp_basename( $file );
    28752875
    28762876    $objects = array( 'attachment' );
  • trunk/src/wp-includes/post.php

    r44687 r44785  
    54755475        // Don't delete the thumb if another attachment uses it.
    54765476        if ( ! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $wpdb->esc_like( $meta['thumb'] ) . '%', $post_id ) ) ) {
    5477             $thumbfile = str_replace( basename( $file ), $meta['thumb'], $file );
     5477            $thumbfile = str_replace( wp_basename( $file ), $meta['thumb'], $file );
    54785478            if ( ! empty( $thumbfile ) ) {
    54795479                $thumbfile = path_join( $uploadpath['basedir'], $thumbfile );
     
    54915491        $intermediate_dir = path_join( $uploadpath['basedir'], dirname( $file ) );
    54925492        foreach ( $meta['sizes'] as $size => $sizeinfo ) {
    5493             $intermediate_file = str_replace( basename( $file ), $sizeinfo['file'], $file );
     5493            $intermediate_file = str_replace( wp_basename( $file ), $sizeinfo['file'], $file );
    54945494            if ( ! empty( $intermediate_file ) ) {
    54955495                $intermediate_file = path_join( $uploadpath['basedir'], $intermediate_file );
     
    56175617            } elseif ( false !== strpos( $file, 'wp-content/uploads' ) ) {
    56185618                // Get the directory name relative to the basedir (back compat for pre-2.7 uploads)
    5619                 $url = trailingslashit( $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file ) ) . basename( $file );
     5619                $url = trailingslashit( $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file ) ) . wp_basename( $file );
    56205620            } else {
    56215621                // It's a newly-uploaded file, therefore $file is relative to the basedir.
     
    57055705    $file = get_attached_file( $post->ID );
    57065706
    5707     if ( ! empty( $imagedata['thumb'] ) && ( $thumbfile = str_replace( basename( $file ), $imagedata['thumb'], $file ) ) && file_exists( $thumbfile ) ) {
     5707    if ( ! empty( $imagedata['thumb'] ) && ( $thumbfile = str_replace( wp_basename( $file ), $imagedata['thumb'], $file ) ) && file_exists( $thumbfile ) ) {
    57085708        /**
    57095709         * Filters the attachment thumbnail file path.
     
    57455745    }
    57465746
    5747     $url = str_replace( basename( $url ), basename( $thumb ), $url );
     5747    $url = str_replace( wp_basename( $url ), wp_basename( $thumb ), $url );
    57485748
    57495749    /**
     
    58975897                if ( $dh = opendir( $dir ) ) {
    58985898                    while ( false !== $file = readdir( $dh ) ) {
    5899                         $file = basename( $file );
     5899                        $file = wp_basename( $file );
    59005900                        if ( substr( $file, 0, 1 ) == '.' ) {
    59015901                            continue;
     
    59165916
    59175917        $types = array();
    5918         // Icon basename - extension = MIME wildcard.
     5918        // Icon wp_basename - extension = MIME wildcard.
    59195919        foreach ( $icon_files as $file => $uri ) {
    5920             $types[ preg_replace( '/^([^.]*).*$/', '$1', basename( $file ) ) ] =& $icon_files[ $file ];
     5920            $types[ preg_replace( '/^([^.]*).*$/', '$1', wp_basename( $file ) ) ] =& $icon_files[ $file ];
    59215921        }
    59225922
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r44309 r44785  
    115115        }
    116116
    117         $name       = basename( $file['file'] );
     117        $name       = wp_basename( $file['file'] );
    118118        $name_parts = pathinfo( $name );
    119119        $name       = trim( substr( $name, 0, -( 1 + strlen( $name_parts['extension'] ) ) ) );
     
    144144
    145145        if ( empty( $attachment->post_title ) ) {
    146             $attachment->post_title = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
     146            $attachment->post_title = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
    147147        }
    148148
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r44719 r44785  
    10631063
    10641064        $attachment = array(
    1065             'post_title'     => basename( $upload['file'] ),
     1065            'post_title'     => wp_basename( $upload['file'] ),
    10661066            'post_content'   => '',
    10671067            'post_type'      => 'attachment',
  • trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php

    r44497 r44785  
    4747    function create_upload_object( $file, $parent = 0 ) {
    4848        $contents = file_get_contents( $file );
    49         $upload   = wp_upload_bits( basename( $file ), null, $contents );
     49        $upload   = wp_upload_bits( wp_basename( $file ), null, $contents );
    5050
    5151        $type = '';
     
    6060
    6161        $attachment = array(
    62             'post_title'     => basename( $upload['file'] ),
     62            'post_title'     => wp_basename( $upload['file'] ),
    6363            'post_content'   => '',
    6464            'post_type'      => 'attachment',
  • trunk/tests/phpunit/tests/ajax/Attachments.php

    r42343 r44785  
    3030        $contents = file_get_contents( $filename );
    3131
    32         $upload     = wp_upload_bits( basename( $filename ), null, $contents );
     32        $upload     = wp_upload_bits( wp_basename( $filename ), null, $contents );
    3333        $attachment = $this->_make_attachment( $upload );
    3434
     
    8181        $contents = file_get_contents( $filename );
    8282
    83         $upload     = wp_upload_bits( basename( $filename ), null, $contents );
     83        $upload     = wp_upload_bits( wp_basename( $filename ), null, $contents );
    8484        $attachment = $this->_make_attachment( $upload );
    8585
  • trunk/tests/phpunit/tests/ajax/MediaEdit.php

    r42343 r44785  
    3333        $contents = file_get_contents( $filename );
    3434
    35         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     35        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    3636        $id     = $this->_make_attachment( $upload );
    3737
     
    6464        $contents = file_get_contents( $filename );
    6565
    66         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     66        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    6767        $id     = $this->_make_attachment( $upload );
    6868
  • trunk/tests/phpunit/tests/blocks/block-parser.php

    r44118 r44785  
    8686     */
    8787    protected function clean_fixture_filename( $filename ) {
    88         $filename = basename( $filename );
     88        $filename = wp_basename( $filename );
    8989        $filename = preg_replace( '/\..+$/', '', $filename );
    9090        return $filename;
  • trunk/tests/phpunit/tests/blocks/render.php

    r44261 r44785  
    359359     */
    360360    protected function clean_fixture_filename( $filename ) {
    361         $filename = basename( $filename );
     361        $filename = wp_basename( $filename );
    362362        $filename = preg_replace( '/\..+$/', '', $filename );
    363363        return $filename;
  • trunk/tests/phpunit/tests/general/template.php

    r43571 r44785  
    232232        $contents = file_get_contents( $filename );
    233233
    234         $upload              = wp_upload_bits( basename( $filename ), null, $contents );
     234        $upload              = wp_upload_bits( wp_basename( $filename ), null, $contents );
    235235        $this->site_icon_url = $upload['url'];
    236236
     
    410410        $filename = DIR_TESTDATA . '/images/test-image.jpg';
    411411        $contents = file_get_contents( $filename );
    412         $upload   = wp_upload_bits( basename( $filename ), null, $contents );
     412        $upload   = wp_upload_bits( wp_basename( $filename ), null, $contents );
    413413
    414414        // Save the data.
  • trunk/tests/phpunit/tests/image/editor.php

    r44577 r44785  
    131131
    132132        // Test with no parameters
    133         $this->assertEquals( 'canola-100x50.jpg', basename( $editor->generate_filename() ) );
     133        $this->assertEquals( 'canola-100x50.jpg', wp_basename( $editor->generate_filename() ) );
    134134
    135135        // Test with a suffix only
    136         $this->assertEquals( 'canola-new.jpg', basename( $editor->generate_filename( 'new' ) ) );
     136        $this->assertEquals( 'canola-new.jpg', wp_basename( $editor->generate_filename( 'new' ) ) );
    137137
    138138        // Test with a destination dir only
     
    140140
    141141        // Test with a suffix only
    142         $this->assertEquals( 'canola-100x50.png', basename( $editor->generate_filename( null, null, 'png' ) ) );
     142        $this->assertEquals( 'canola-100x50.png', wp_basename( $editor->generate_filename( null, null, 'png' ) ) );
    143143
    144144        // Combo!
  • trunk/tests/phpunit/tests/image/intermediateSize.php

    r42343 r44785  
    1818    public function _make_attachment( $file, $parent_post_id = 0 ) {
    1919        $contents = file_get_contents( $file );
    20         $upload   = wp_upload_bits( basename( $file ), null, $contents );
     20        $upload   = wp_upload_bits( wp_basename( $file ), null, $contents );
    2121
    2222        return parent::_make_attachment( $upload, $parent_post_id );
  • 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 );
  • 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 );
  • trunk/tests/phpunit/tests/media.php

    r44528 r44785  
    15251525        $hash = 'e' . time() . rand( 100, 999 );
    15261526
    1527         $filename_base = basename( $image_meta['file'], '.png' );
     1527        $filename_base = wp_basename( $image_meta['file'], '.png' );
    15281528
    15291529        // Add the hash to the image URL
  • trunk/tests/phpunit/tests/post/attachments.php

    r42343 r44785  
    2828        $contents = file_get_contents( $filename );
    2929
    30         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     30        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    3131        $this->assertTrue( empty( $upload['error'] ) );
    3232
     
    4040        // medium, medium_large, and full size will both point to the original
    4141        $downsize = image_downsize( $id, 'medium' );
    42         $this->assertEquals( basename( $upload['file'] ), basename( $downsize[0] ) );
     42        $this->assertEquals( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) );
    4343        $this->assertEquals( 50, $downsize[1] );
    4444        $this->assertEquals( 50, $downsize[2] );
    4545
    4646        $downsize = image_downsize( $id, 'medium_large' );
    47         $this->assertEquals( basename( $upload['file'] ), basename( $downsize[0] ) );
     47        $this->assertEquals( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) );
    4848        $this->assertEquals( 50, $downsize[1] );
    4949        $this->assertEquals( 50, $downsize[2] );
    5050
    5151        $downsize = image_downsize( $id, 'full' );
    52         $this->assertEquals( basename( $upload['file'] ), basename( $downsize[0] ) );
     52        $this->assertEquals( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) );
    5353        $this->assertEquals( 50, $downsize[1] );
    5454        $this->assertEquals( 50, $downsize[2] );
     
    6767        $contents = file_get_contents( $filename );
    6868
    69         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     69        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    7070        $this->assertTrue( empty( $upload['error'] ) );
    7171
     
    8787        // image_downsize() should return the correct images and sizes
    8888        $downsize = image_downsize( $id, 'thumbnail' );
    89         $this->assertEquals( 'a2-small-150x150.jpg', basename( $downsize[0] ) );
     89        $this->assertEquals( 'a2-small-150x150.jpg', wp_basename( $downsize[0] ) );
    9090        $this->assertEquals( 150, $downsize[1] );
    9191        $this->assertEquals( 150, $downsize[2] );
     
    9393        // medium, medium_large, and full will both point to the original
    9494        $downsize = image_downsize( $id, 'medium' );
    95         $this->assertEquals( 'a2-small.jpg', basename( $downsize[0] ) );
     95        $this->assertEquals( 'a2-small.jpg', wp_basename( $downsize[0] ) );
    9696        $this->assertEquals( 400, $downsize[1] );
    9797        $this->assertEquals( 300, $downsize[2] );
    9898
    9999        $downsize = image_downsize( $id, 'medium_large' );
    100         $this->assertEquals( 'a2-small.jpg', basename( $downsize[0] ) );
     100        $this->assertEquals( 'a2-small.jpg', wp_basename( $downsize[0] ) );
    101101        $this->assertEquals( 400, $downsize[1] );
    102102        $this->assertEquals( 300, $downsize[2] );
    103103
    104104        $downsize = image_downsize( $id, 'full' );
    105         $this->assertEquals( 'a2-small.jpg', basename( $downsize[0] ) );
     105        $this->assertEquals( 'a2-small.jpg', wp_basename( $downsize[0] ) );
    106106        $this->assertEquals( 400, $downsize[1] );
    107107        $this->assertEquals( 300, $downsize[2] );
     
    123123        $contents = file_get_contents( $filename );
    124124
    125         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     125        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    126126        $this->assertTrue( empty( $upload['error'] ) );
    127127
     
    147147        // image_downsize() should return the correct images and sizes
    148148        $downsize = image_downsize( $id, 'thumbnail' );
    149         $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', basename( $downsize[0] ) );
     149        $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', wp_basename( $downsize[0] ) );
    150150        $this->assertEquals( 150, $downsize[1] );
    151151        $this->assertEquals( 150, $downsize[2] );
    152152
    153153        $downsize = image_downsize( $id, 'medium' );
    154         $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', basename( $downsize[0] ) );
     154        $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', wp_basename( $downsize[0] ) );
    155155        $this->assertEquals( 400, $downsize[1] );
    156156        $this->assertEquals( 602, $downsize[2] );
    157157
    158158        $downsize = image_downsize( $id, 'medium_large' );
    159         $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', basename( $downsize[0] ) );
     159        $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', wp_basename( $downsize[0] ) );
    160160        $this->assertEquals( 600, $downsize[1] );
    161161        $this->assertEquals( 904, $downsize[2] );
    162162
    163163        $downsize = image_downsize( $id, 'full' );
    164         $this->assertEquals( '2007-06-17DSC_4173.jpg', basename( $downsize[0] ) );
     164        $this->assertEquals( '2007-06-17DSC_4173.jpg', wp_basename( $downsize[0] ) );
    165165        $this->assertEquals( 680, $downsize[1] );
    166166        $this->assertEquals( 1024, $downsize[2] );
     
    182182        $contents = file_get_contents( $filename );
    183183
    184         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     184        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    185185        $this->assertTrue( empty( $upload['error'] ) );
    186186
     
    225225        $contents = file_get_contents( $filename );
    226226
    227         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     227        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    228228        $this->assertTrue( empty( $upload['error'] ) );
    229229
     
    242242        $contents = file_get_contents( $filename );
    243243
    244         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     244        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    245245        $this->assertTrue( empty( $upload['error'] ) );
    246246
     
    268268        $contents = file_get_contents( $filename );
    269269
    270         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     270        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    271271        $this->assertTrue( empty( $upload['error'] ) );
    272272
     
    300300        $contents = file_get_contents( $filename );
    301301
    302         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     302        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    303303        $this->assertTrue( empty( $upload['error'] ) );
    304304
     
    325325        $contents = file_get_contents( $filename );
    326326
    327         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     327        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    328328        $this->assertTrue( empty( $upload['error'] ) );
    329329
     
    350350        $contents = file_get_contents( $filename );
    351351
    352         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     352        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    353353        $this->assertTrue( empty( $upload['error'] ) );
    354354
     
    378378        $contents = file_get_contents( $filename );
    379379
    380         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     380        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    381381        $this->assertTrue( empty( $upload['error'] ) );
    382382
     
    406406        $contents = file_get_contents( $filename );
    407407
    408         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     408        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    409409        $this->assertTrue( empty( $upload['error'] ) );
    410410
     
    433433        $contents = file_get_contents( $filename );
    434434
    435         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     435        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    436436        $this->assertTrue( empty( $upload['error'] ) );
    437437
     
    455455        $contents = file_get_contents( $filename );
    456456
    457         $upload        = wp_upload_bits( basename( $filename ), null, $contents );
     457        $upload        = wp_upload_bits( wp_basename( $filename ), null, $contents );
    458458        $attachment_id = $this->_make_attachment( $upload );
    459459
     
    473473        $contents = file_get_contents( $filename );
    474474
    475         $upload        = wp_upload_bits( basename( $filename ), null, $contents );
     475        $upload        = wp_upload_bits( wp_basename( $filename ), null, $contents );
    476476        $attachment_id = $this->_make_attachment( $upload );
    477477
     
    490490        $contents = file_get_contents( $filename );
    491491
    492         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     492        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    493493
    494494        $this->assertFalse( $upload['error'] );
     
    496496        add_filter( 'upload_mimes', array( $this, 'blacklist_jpg_mime_type' ) );
    497497
    498         $upload = wp_upload_bits( basename( $filename ), null, $contents );
     498        $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    499499
    500500        remove_filter( 'upload_mimes', array( $this, 'blacklist_jpg_mime_type' ) );
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r44234 r44785  
    14361436        );
    14371437
    1438         $filename = basename( $this->test_file2 );
     1438        $filename = wp_basename( $this->test_file2 );
    14391439
    14401440        $request = new WP_REST_Request( 'GET', '/wp/v2/media' );
  • trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php

    r42343 r44785  
    2121        $filename = ( DIR_TESTDATA . '/images/waffles.jpg' );
    2222        $contents = file_get_contents( $filename );
    23         $upload   = wp_upload_bits( basename( $filename ), null, $contents );
     23        $upload   = wp_upload_bits( wp_basename( $filename ), null, $contents );
    2424
    2525        $this->attachment_id   = $this->_make_attachment( $upload, self::$post_id );
Note: See TracChangeset for help on using the changeset viewer.