Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#21159 closed defect (bug) (fixed)

get_bookmark() errors with non-existent id

Reported by: Mike Stop Continues Owned by: nacin
Milestone: 3.5 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch commit
Focuses: Cc:


Using get_bookmark() with a non-existent id produces the following errors:

Notice: Trying to get property of non-object in /homepages/43/d372234873/htdocs/mikestopcontinues/wp-includes/bookmark.php on line 36

Warning: Creating default object from empty value in /homepages/43/d372234873/htdocs/mikestopcontinues/wp-includes/bookmark.php on line 36

Notice: Undefined property: stdClass::$link_id in /homepages/43/d372234873/htdocs/mikestopcontinues/wp-includes/bookmark.php on line 37

Notice: Undefined property: stdClass::$link_id in /homepages/43/d372234873/htdocs/mikestopcontinues/wp-includes/bookmark.php on line 281

My thought would be to add if(is_null($_bookmark)) return false; to line 36 of wp-includes/bookmark.php, though it might be better to if(is_null($_bookmark)) { wp_cache_add($bookmark, $_bookmark, 'bookmark'); return $_bookmark;}

Attachments (1)

bookmark-validation.diff (891 bytes) - added by wonderboymusic 8 years ago.

Download all attachments as: .zip

Change History (4)

#1 @wonderboymusic
8 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.5

$_bookmark will be null if $wpdb->get_row returns nothing. Validates the returned value before querying and setting cache. Even though links are eventually being removed, the remaining tickets should be fixed for #21307 before moving to plugin.

#2 @nacin
8 years ago

  • Keywords commit added

#3 @nacin
8 years ago

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

In [21829]:

Don't cache a non-existent link in get_bookmark(). props wonderboymusic, fixes #21159.

Note: See TracTickets for help on using tickets.