Make WordPress Core


Ignore:
Timestamp:
11/21/2014 06:34:23 AM (10 years ago)
Author:
SergeyBiryukov
Message:

Replace invalid use of ltrim() in attachment_url_to_postid() with substr().

props bradyvercher.
fixes #30346.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r30132 r30501  
    444444    }
    445445
     446    /**
     447     * @ticket 30346
     448     */
     449    function test_attachment_url_to_postid() {
     450        $image_path = '2014/11/' . $this->img_name;
     451        $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array(
     452            'post_mime_type' => 'image/jpeg',
     453            'post_type'      => 'attachment',
     454        ) );
     455
     456        $image_url  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path;
     457        $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) );
     458
     459        add_filter( 'upload_dir', array( $this, '_upload_dir' ) );
     460        $image_url = 'http://192.168.1.20.com/wp-content/uploads/' . $image_path;
     461        $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) );
     462        remove_filter( 'upload_dir', array( $this, '_upload_dir' ) );
     463    }
     464
     465    function _upload_dir( $dir ) {
     466        $dir['baseurl'] = 'http://192.168.1.20.com/wp-content/uploads';
     467        return $dir;
     468    }
     469
    446470}
Note: See TracChangeset for help on using the changeset viewer.