From be707cd61434c229aa3cea205af956e79240bdf1 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 1 Nov 2014 19:45:25 +0000 Subject: [PATCH] In `wp_xmlrpc_server` methods, for comprehensibility: * initialize arrays in loops, instead of overriding an uninitialized array each time * in `->blogger_getRecentPosts()` and `->mw_getRecentPosts()`, remove the extra loops by only setting one `array` See #30224. Built from https://develop.svn.wordpress.org/trunk@30153 git-svn-id: http://core.svn.wordpress.org/trunk@30153 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-xmlrpc-server.php | 28 ++++++++++---------------- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 6e68d0378d..80fdf0810a 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -2763,6 +2763,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( $all_tags = get_tags() ) { foreach( (array) $all_tags as $tag ) { + $struct = array(); $struct['tag_id'] = $tag->term_id; $struct['name'] = $tag->name; $struct['count'] = $tag->count; @@ -3220,6 +3221,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( ! get_post($post_id) ) return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + $comment = array(); $comment['comment_post_ID'] = $post_id; if ( $logged_in ) { @@ -3483,6 +3485,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( !current_user_can( 'manage_options' ) ) return new IXR_Error( 403, __( 'You are not allowed to update options.' ) ); + $option_names = array(); foreach ( $options as $o_name => $o_value ) { $option_names[] = $o_name; if ( !array_key_exists( $o_name, $this->blog_options ) ) @@ -3628,6 +3631,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( current_theme_supports( 'post-formats' ) ) { $supported = get_theme_support( 'post-formats' ); + $data = array(); $data['all'] = $formats; $data['supported'] = $supported[0]; @@ -4074,6 +4078,7 @@ class wp_xmlrpc_server extends IXR_Server { return $this->error; } + $recent_posts = array(); foreach ($posts_list as $entry) { if ( !current_user_can( 'edit_post', $entry['ID'] ) ) continue; @@ -4085,18 +4090,12 @@ class wp_xmlrpc_server extends IXR_Server { $content .= ''.$categories.''; $content .= wp_unslash($entry['post_content']); - $struct[] = array( + $recent_posts[] = array( 'userid' => $entry['post_author'], 'dateCreated' => $post_date, 'content' => $content, 'postid' => (string) $entry['ID'], ); - - } - - $recent_posts = array(); - for ( $j=0; $j $post_date, 'userid' => $entry['post_author'], 'postid' => (string) $entry['ID'], @@ -5174,15 +5173,8 @@ class wp_xmlrpc_server extends IXR_Server { 'date_modified' => $post_modified, 'date_modified_gmt' => $post_modified_gmt, 'sticky' => ( $entry['post_type'] === 'post' && is_sticky( $entry['ID'] ) ), + 'wp_post_thumbnail' => get_post_thumbnail_id( $entry['ID'] ) ); - - $entry_index = count( $struct ) - 1; - $struct[ $entry_index ][ 'wp_post_thumbnail' ] = get_post_thumbnail_id( $entry['ID'] ); - } - - $recent_posts = array(); - for ( $j=0; $j 'all')) ) { foreach ( $cats as $cat ) { + $struct = array(); $struct['categoryId'] = $cat->term_id; $struct['parentId'] = $cat->parent; $struct['description'] = $cat->name; @@ -5436,6 +5429,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { foreach ( $cats as $cat ) { + $struct = array(); $struct['categoryId'] = $cat->term_id; $struct['categoryName'] = $cat->name; diff --git a/wp-includes/version.php b/wp-includes/version.php index cf3bb63263..f84c1e914d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30152'; +$wp_version = '4.1-alpha-30153'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.