attachment_url_to_postid() should always return an integer.
props nathan_dawson, ashfame. fixes #31044. git-svn-id: https://develop.svn.wordpress.org/trunk@31239 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a79297ba2d
commit
a036114a4d
@ -3295,7 +3295,7 @@ function wp_maybe_generate_attachment_metadata( $attachment ) {
|
|||||||
* @global wpdb $wpdb WordPress database abstraction object.
|
* @global wpdb $wpdb WordPress database abstraction object.
|
||||||
*
|
*
|
||||||
* @param string $url The URL to resolve.
|
* @param string $url The URL to resolve.
|
||||||
* @return int The found post ID.
|
* @return int The found post ID, or 0 on failure.
|
||||||
*/
|
*/
|
||||||
function attachment_url_to_postid( $url ) {
|
function attachment_url_to_postid( $url ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
@ -3312,9 +3312,8 @@ function attachment_url_to_postid( $url ) {
|
|||||||
$path
|
$path
|
||||||
);
|
);
|
||||||
$post_id = $wpdb->get_var( $sql );
|
$post_id = $wpdb->get_var( $sql );
|
||||||
if ( ! empty( $post_id ) ) {
|
|
||||||
return (int) $post_id;
|
return (int) $post_id;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -501,6 +501,15 @@ VIDEO;
|
|||||||
return $dir;
|
return $dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 31044
|
||||||
|
*/
|
||||||
|
function test_attachment_url_to_postid_with_empty_url() {
|
||||||
|
$post_id = attachment_url_to_postid( '' );
|
||||||
|
$this->assertInternalType( 'int', $post_id );
|
||||||
|
$this->assertEquals( 0, $post_id );
|
||||||
|
}
|
||||||
|
|
||||||
function test_wp_check_filetype() {
|
function test_wp_check_filetype() {
|
||||||
$url = 'http://example.com/testFile.mp4?autoplay=true&otherstuff=false';
|
$url = 'http://example.com/testFile.mp4?autoplay=true&otherstuff=false';
|
||||||
$filetype = wp_check_filetype( $url );
|
$filetype = wp_check_filetype( $url );
|
||||||
|
Loading…
Reference in New Issue
Block a user