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

props bradyvercher.
fixes #30346.
Built from https://develop.svn.wordpress.org/trunk@30501


git-svn-id: http://core.svn.wordpress.org/trunk@30490 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-11-21 06:35:22 +00:00
parent aad05ece16
commit 8f2842a07e
2 changed files with 6 additions and 2 deletions

View File

@ -3269,7 +3269,11 @@ function attachment_url_to_postid( $url ) {
global $wpdb; global $wpdb;
$dir = wp_upload_dir(); $dir = wp_upload_dir();
$path = ltrim( $url, $dir['baseurl'] . '/' ); $path = $url;
if ( 0 === strpos( $path, $dir['baseurl'] . '/' ) ) {
$path = substr( $path, strlen( $dir['baseurl'] . '/' ) );
}
$sql = $wpdb->prepare( $sql = $wpdb->prepare(
"SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s", "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s",

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.1-beta2-30500'; $wp_version = '4.1-beta2-30501';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.