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
This commit is contained in:
Ryan Boren 2012-02-14 18:46:11 +00:00
parent ee5aae19ef
commit 3d51611c08
1 changed files with 21 additions and 6 deletions

View File

@ -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];