WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/22/2010 07:05:50 AM (10 years ago)
Author:
dd32
Message:

Add some defensive checks to Canonical redirection of %category% to ensure notices are not thrown. Props jfarthing84 for pointing out possibility. See #11907

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/canonical.php

    r13781 r13798  
    168168            $category = get_term_by('slug', get_query_var('category_name'), 'category');
    169169            $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category');
    170             if ( ! in_array($category, $post_terms) )
     170            if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category, $post_terms) ) )
    171171                $redirect_url = get_permalink($wp_query->get_queried_object_id());
    172172        }
Note: See TracChangeset for help on using the changeset viewer.