WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#7507 closed defect (bug) (fixed)

'wp_list_bookmarks()' and 'category_name' with non-existent category

Reported by: therks Owned by: anonymous
Priority: lowest Milestone: 2.8
Component: Template Version: 2.6
Severity: trivial Keywords: has-patch tested
Cc:

Description

When using 'wp_list_bookmarks()', if you specify a non-existent category with the 'category_name' parameter it shows all bookmarks from all categories. Should just return nothing, shouldn't it?

Attachments (2)

7507.patch (648 bytes) - added by Viper007Bond 4 years ago.
7507.2.patch (721 bytes) - added by Viper007Bond 4 years ago.
Avoid double get_term_by() call

Download all attachments as: .zip

Change History (13)

comment:1 therks5 years ago

Bah, I forgot to mention that categorize also has to be set to 0.
Example:

wp_list_bookmarks('categorize=0&category_name=IDontExist');

comment:2 Denis-de-Bernardy4 years ago

  • Milestone set to Future Release
  • Priority changed from normal to lowest
  • Severity changed from normal to trivial

comment:3 Denis-de-Bernardy4 years ago

  • Component changed from General to Template
  • Keywords needs-patch added; wp_list_bookmarks category_name removed

comment:4 Denis-de-Bernardy4 years ago

confirmed in 2.8. the issue is in get_bookmarks().

if category name is not empty and it returns no terms, it should:

  1. cache an empty result
  2. return

Viper007Bond4 years ago

comment:6 Viper007Bond4 years ago

  • Keywords has-patch needs-testing added; needs-patch removed
  • Milestone changed from Future Release to 2.8

comment:8 Denis-de-Bernardy4 years ago

the point would be to not get the term twice. It's negligible optimization, if any optimization at all, but you never know when the cache decides to fail for some reason... :P

comment:9 Viper007Bond4 years ago

get_term_by() doesn't cache, so yes it'd be best to only do it once. Good catch.

Viper007Bond4 years ago

Avoid double get_term_by() call

comment:10 Denis-de-Bernardy4 years ago

  • Keywords tested added; needs-testing removed

comment:11 ryan4 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11064]) Return empty list if requests bookmark category does not exist. Props Viper007Bond. fixes #7507

Note: See TracTickets for help on using tickets.