[wp-trac] [WordPress Trac] #46420: Warnings on front-end when trying to display the archive for a non-existent term of a custom taxonomy
WordPress Trac
noreply at wordpress.org
Tue Mar 5 15:10:46 UTC 2019
#46420: Warnings on front-end when trying to display the archive for a non-existent
term of a custom taxonomy
--------------------------+-----------------------------
Reporter: zaantar | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: 5.1
Severity: minor | Keywords:
Focuses: template |
--------------------------+-----------------------------
Steps to reproduce the issue:
1. Clean site with a Twenty Seventeen theme (but it happens with other
themes as well)
2. Disable permalinks.
3. Register a custom taxonomy (for example, "kind") and create a term
("k1").
4. Open this malformed URL in the browser (replace "localhost" if
appropriate, of course): http://localhost/?kind=,k1 - note that the term
must be valid in order for the issue to occur.
5. Observe the warning:
{{{
Notice: Trying to get property of non-object in /var/www/html/wp-includes
/general-template.php on line 2795
Call Stack
# Time Memory Function Location
1 0.0140 363912 {main}( ) .../index.php:0
2 0.0862 365080 require( '/var/www/html/wp-blog-header.php' )
.../index.php:17
3 1.0117 5400536 require_once( '/var/www/html/wp-includes/template-
loader.php' ) .../wp-blog-header.php:19
4 1.0221 5485576 include( '/var/www/html/wp-
content/themes/twentyseventeen/archive.php' ) .../template-
loader.php:77
5 1.0221 5485576 get_header( ??? ) .../archive.php:13
6 1.0221 5485952 locate_template( ???, ???, ??? )
.../general-template.php:41
7 1.0227 5486048 load_template( ???, ??? )
.../template.php:653
8 1.0234 5486480 require_once( '/var/www/html/wp-
content/themes/twentyseventeen/header.php' ) .../template.php:704
9 1.0263 5495688 wp_head( ) .../header.php:22
10 1.0263 5495688 do_action( ???, ??? ) .../general-
template.php:2668
11 1.0264 5496064 WP_Hook->do_action( ??? ) .../plugin.php:465
12 1.0264 5496064 WP_Hook->apply_filters( ???, ??? ) .../class-
wp-hook.php:310
13 1.0673 5829504 feed_links_extra( ??? ) .../class-wp-hook.php:286
}}}
The problem is caused by these two lines in wp-includes/general-
template.php:
{{{
$term = get_queried_object();
$tax = get_taxonomy( $term->taxonomy );
}}}
In this case, get_queried_object() returns null and the code is not ready
for that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46420>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list