get_comments() can return int, so a few places need to check if the return value is traversable before passing what is assumed to be an array.

See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32600 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-05-25 17:58:52 +00:00
parent 768115d353
commit bd06ad2725
4 changed files with 20 additions and 16 deletions
+5 -4
View File
@@ -3196,12 +3196,13 @@ class wp_xmlrpc_server extends IXR_Server {
if ( isset($struct['number']) )
$number = absint($struct['number']);
$comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
$comments = get_comments( array( 'status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
$comments_struct = array();
foreach ( $comments as $comment ) {
$comments_struct[] = $this->_prepare_comment( $comment );
if ( is_array( $comments ) ) {
foreach ( $comments as $comment ) {
$comments_struct[] = $this->_prepare_comment( $comment );
}
}
return $comments_struct;