From 3d51611c08637b7bc6f7cada7fc770ae9ce60600 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 14 Feb 2012 18:46:11 +0000 Subject: [PATCH] Don't assume elements exist. Check to avoid notices. Props kurtpayne, rmccue. fixes #19914 git-svn-id: https://develop.svn.wordpress.org/trunk@19926 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-app.php | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/wp-app.php b/wp-app.php index 7e0edba91e..09eebea901 100644 --- a/wp-app.php +++ b/wp-app.php @@ -400,8 +400,10 @@ EOD; log_app('Received entry:', print_r($entry,true)); $catnames = array(); - foreach ( $entry->categories as $cat ) { - array_push($catnames, $cat["term"]); + if ( !empty( $entry->categories ) ) { + foreach ( $entry->categories as $cat ) { + array_push($catnames, $cat["term"]); + } } $wp_cats = get_categories(array('hide_empty' => false)); @@ -423,10 +425,23 @@ EOD; $blog_ID = get_current_blog_id(); $post_status = ($publish) ? 'publish' : 'draft'; $post_author = (int) $user_ID; - $post_title = $entry->title[1]; - $post_content = $entry->content[1]; - $post_excerpt = $entry->summary[1]; - $pubtimes = $this->get_publish_time($entry->published); + + $post_title = ''; + $post_content = ''; + $post_excerpt = ''; + $pubtimes = ''; + + if ( isset( $entry->title ) && is_array( $entry->title ) && !empty( $entry->title[1] ) ) + $post_title = (string) $entry->title[1]; + if ( isset( $entry->content ) && is_array( $entry->content ) && !empty( $entry->content[1] ) ) + $post_content = (string) $entry->content[1]; + if ( isset( $entry->summary ) && is_array( $entry->summary ) && !empty( $entry->summary[1] ) ) + $post_excerpt = (string) $entry->summary[1]; + if ( !empty( $entry->published ) ) + $pubtimes = (string) $entry->published; + + $pubtimes = $this->get_publish_time( $pubtimes ); + $post_date = $pubtimes[0]; $post_date_gmt = $pubtimes[1];