From 8f2842a07ea1b62b8959246f035db6bdb415261b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 21 Nov 2014 06:35:22 +0000 Subject: [PATCH] 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 --- wp-includes/media.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 48be78e6fc..00bf9db3d9 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -3269,7 +3269,11 @@ function attachment_url_to_postid( $url ) { global $wpdb; $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( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s", diff --git a/wp-includes/version.php b/wp-includes/version.php index 128a519b15..6db466bac3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.