WordPress.org

Make WordPress Core

Changeset 25310


Ignore:
Timestamp:
09/10/13 02:27:24 (7 months ago)
Author:
wonderboymusic
Message:

Make sure the queried object is non-null before accessing its properties.

Props markoheijnen, ryan.
Fixes #21394.

Location:
trunk/src/wp-includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category-template.php

    r25119 r25310  
    466466        if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) { 
    467467            $current_term_object = get_queried_object(); 
    468             if ( $r['taxonomy'] == $current_term_object->taxonomy ) 
     468            if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy ) 
    469469                $r['current_category'] = get_queried_object_id(); 
    470470        } 
     
    10381038 */ 
    10391039function term_description( $term = 0, $taxonomy = 'post_tag' ) { 
    1040     if ( !$term && ( is_tax() || is_tag() || is_category() ) ) { 
     1040    if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) { 
    10411041        $term = get_queried_object(); 
    1042         $taxonomy = $term->taxonomy; 
    1043         $term = $term->term_id; 
     1042        if ( $term ) { 
     1043            $taxonomy = $term->taxonomy; 
     1044            $term = $term->term_id; 
     1045        } 
    10441046    } 
    10451047    $description = get_term_field( 'description', $term, $taxonomy ); 
  • trunk/src/wp-includes/general-template.php

    r25291 r25310  
    593593    if ( is_tax() ) { 
    594594        $term = get_queried_object(); 
    595         $tax = get_taxonomy( $term->taxonomy ); 
    596         $title = single_term_title( $tax->labels->name . $t_sep, false ); 
     595        if ( $term ) { 
     596            $tax = get_taxonomy( $term->taxonomy ); 
     597            $title = single_term_title( $tax->labels->name . $t_sep, false ); 
     598        } 
    597599    } 
    598600 
     
    600602    if ( is_author() ) { 
    601603        $author = get_queried_object(); 
    602         $title = $author->display_name; 
     604        if ( $author ) 
     605            $title = $author->display_name; 
    603606    } 
    604607 
     
    16931696        $term = get_queried_object(); 
    16941697 
    1695         $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); 
    1696         $href = get_category_feed_link( $term->term_id ); 
     1698        if ( $term ) { 
     1699            $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); 
     1700            $href = get_category_feed_link( $term->term_id ); 
     1701        } 
    16971702    } elseif ( is_tag() ) { 
    16981703        $term = get_queried_object(); 
    16991704 
    1700         $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); 
    1701         $href = get_tag_feed_link( $term->term_id ); 
     1705        if ( $term ) { 
     1706            $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); 
     1707            $href = get_tag_feed_link( $term->term_id ); 
     1708        } 
    17021709    } elseif ( is_author() ) { 
    17031710        $author_id = intval( get_query_var('author') ); 
     
    17101717    } elseif ( is_post_type_archive() ) { 
    17111718        $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) ); 
    1712         $href = get_post_type_archive_feed_link( get_queried_object()->name ); 
     1719        $post_type_obj = get_queried_object(); 
     1720        if ( $post_type_obj ) 
     1721            $href = get_post_type_archive_feed_link( $post_type_obj->name ); 
    17131722    } 
    17141723 
  • trunk/src/wp-includes/link-template.php

    r25085 r25310  
    714714 */ 
    715715function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { 
    716     if ( is_null( $term ) ) { 
     716    if ( is_null( $term ) ) 
    717717        $term = get_queried_object(); 
    718     } 
     718 
     719    if ( ! $term ) 
     720        return; 
    719721 
    720722    $tax = get_taxonomy( $term->taxonomy ); 
    721     if ( !current_user_can($tax->cap->edit_terms) ) 
     723    if ( ! current_user_can( $tax->cap->edit_terms ) ) 
    722724        return; 
    723725 
  • trunk/src/wp-includes/template.php

    r25291 r25310  
    257257        // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object 
    258258        $post = get_queried_object(); 
    259         $pagename = $post->post_name; 
     259        if ( $post ) 
     260            $pagename = $post->post_name; 
    260261    } 
    261262 
Note: See TracChangeset for help on using the changeset viewer.