XML-RPC: Save enclosures with a trailing new line. fixes #23219.

git-svn-id: http://core.svn.wordpress.org/trunk@24623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-07-10 03:34:35 +00:00
parent b6c1023caa
commit 49bb647dda
1 changed files with 9 additions and 11 deletions

View File

@ -4314,22 +4314,20 @@ class wp_xmlrpc_server extends IXR_Server {
return strval($post_ID);
}
function add_enclosure_if_new($post_ID, $enclosure) {
function add_enclosure_if_new( $post_ID, $enclosure ) {
if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
$encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'];
$encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n";
$found = false;
foreach ( (array) get_post_custom($post_ID) as $key => $val) {
if ($key == 'enclosure') {
foreach ( (array) $val as $enc ) {
if ($enc == $encstring) {
$found = true;
break 2;
}
if ( $enclosures = get_post_meta( $post_ID, 'enclosure' ) ) {
foreach ( $enclosures as $enc ) {
// This method used to omit the trailing new line. #23219
if ( rtrim( $enc, "\n" ) == rtrim( $encstring, "\n" ) ) {
$found = true;
break;
}
}
}
if (!$found)
if ( ! $found )
add_post_meta( $post_ID, 'enclosure', $encstring );
}
}