From c254787f0cd63ec5d3875b0144bf5e15136abfe2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 29 Mar 2013 19:10:31 +0000 Subject: [PATCH] Make a copy of post content to avoid changing it in get_the_image(). Remove unnecessary assignment from get_the_media(). props wonderboymusic for initial patch. fixes #23888. git-svn-id: http://core.svn.wordpress.org/trunk@23869 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index f41f63ea54..9ba8e295ec 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -2069,9 +2069,8 @@ function get_the_media( $type, &$post = null ) { } } - // these functions expected a reference, not a value - $_content = $post->post_content; - $content =& $_content; + // these functions expect a reference, so we should make a copy of post content to avoid changing it + $content = $post->post_content; $htmls = get_content_media( $type, $content, true, true ); if ( ! empty( $htmls ) ) { @@ -2386,7 +2385,7 @@ function get_the_image( $attached_size = 'full', &$post = null ) { $count = 1; $matches = array(); - $content =& $post->post_content; + $content = $post->post_content; if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) { foreach ( $matches as $shortcode ) { @@ -2415,7 +2414,7 @@ function get_the_image( $attached_size = 'full', &$post = null ) { return $post->format_content; } - $content =& $post->post_content; + $content = $post->post_content; $htmls = get_content_images( $content, true, true, 1 ); if ( ! empty( $htmls ) ) { $html = reset( $htmls );