WordPress.org

Make WordPress Core

Changeset 19926


Ignore:
Timestamp:
02/14/2012 06:46:11 PM (8 years ago)
Author:
ryan
Message:

Don't assume elements exist. Check to avoid notices. Props kurtpayne, rmccue. fixes #19914

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-app.php

    r19784 r19926  
    401401
    402402        $catnames = array();
    403         foreach ( $entry->categories as $cat ) {
    404             array_push($catnames, $cat["term"]);
     403        if ( !empty( $entry->categories ) ) {
     404            foreach ( $entry->categories as $cat ) {
     405                array_push($catnames, $cat["term"]);
     406            }
    405407        }
    406408
     
    424426        $post_status = ($publish) ? 'publish' : 'draft';
    425427        $post_author = (int) $user_ID;
    426         $post_title = $entry->title[1];
    427         $post_content = $entry->content[1];
    428         $post_excerpt = $entry->summary[1];
    429         $pubtimes = $this->get_publish_time($entry->published);
     428
     429        $post_title   = '';
     430        $post_content = '';
     431        $post_excerpt = '';
     432        $pubtimes     = '';
     433       
     434        if ( isset( $entry->title ) && is_array( $entry->title ) && !empty( $entry->title[1] ) )
     435            $post_title = (string) $entry->title[1];
     436        if ( isset( $entry->content ) && is_array( $entry->content ) && !empty( $entry->content[1] ) )
     437            $post_content = (string) $entry->content[1];
     438        if ( isset( $entry->summary ) && is_array( $entry->summary ) && !empty( $entry->summary[1] ) )
     439            $post_excerpt = (string) $entry->summary[1];
     440        if ( !empty( $entry->published ) )
     441            $pubtimes = (string) $entry->published;
     442       
     443        $pubtimes = $this->get_publish_time( $pubtimes );
     444
    430445        $post_date = $pubtimes[0];
    431446        $post_date_gmt = $pubtimes[1];
Note: See TracChangeset for help on using the changeset viewer.