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

git-svn-id: http://core.svn.wordpress.org/trunk@21829 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-09-13 16:41:43 +00:00
parent f54edf701a
commit 94c34141b3
1 changed files with 7 additions and 2 deletions

View File

@ -33,11 +33,16 @@ function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw') {
$_bookmark = & $GLOBALS['link']; $_bookmark = & $GLOBALS['link'];
} elseif ( ! $_bookmark = wp_cache_get($bookmark, 'bookmark') ) { } elseif ( ! $_bookmark = wp_cache_get($bookmark, 'bookmark') ) {
$_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark)); $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark));
$_bookmark->link_category = array_unique( wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')) ); if ( $_bookmark ) {
wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark'); $_bookmark->link_category = array_unique( wp_get_object_terms( $_bookmark->link_id, 'link_category', array( 'fields' => 'ids' ) ) );
wp_cache_add( $_bookmark->link_id, $_bookmark, 'bookmark' );
}
} }
} }
if ( ! $_bookmark )
return $_bookmark;
$_bookmark = sanitize_bookmark($_bookmark, $filter); $_bookmark = sanitize_bookmark($_bookmark, $filter);
if ( $output == OBJECT ) { if ( $output == OBJECT ) {