Make WordPress Core

Opened 2 years ago

Last modified 23 months ago

#57505 new defect (bug)

category archive url ending with "/0" should be 404

Reported by: obache's profile obache Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description

First, if URL is "/category/cat1/0", first, it is recognized as category_name="cat1/0",
then "is_category=true" and category archive template should be selected.

But for really query, category_name="0" and empty($q["category_name"])==true,
so it is recognized as "category is not specified", then tax_query will be empty, and queried_object==null.

Finally, category template will be confused.
No category is selected, any category related information are broken (maybe rise warnings or errors).
Any recent posts of any public post types will be displayed even if its post_type dose not belong to core 'category' taxonomy.

Change History (3)

#1 @obache
2 years ago

questioned codes in WP_Query::parse_tax_query().

                        if ( $t->query_var && ! empty( $q[ $t->query_var ] ) ) {

whereas $t->query_var is 'category_name', and $q['category_name'] is 0;

should it be strlen( $q[ $t->query_var ] ) > 0 instead of ! empty( $q[ $t->query_var ] ) ?

#2 @obache
2 years ago

maybe related to #50149

#3 @zareidev
23 months ago

  • Summary changed from cagegory archive url ending with "/0" should be 404 to category archive url ending with "/0" should be 404
Note: See TracTickets for help on using tickets.