]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/bookmark.php
Wordpress 3.6-scripts
[autoinstalls/wordpress.git] / wp-includes / bookmark.php
index 8248e3a64f69653647c6e0c379d16d4be1775169..9a3ac6107c2526e304c9f42c8279d057733c8341 100644 (file)
@@ -33,11 +33,16 @@ function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw') {
                        $_bookmark = & $GLOBALS['link'];
                } 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->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 ) {
+                               $_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);
 
        if ( $output == OBJECT ) {
@@ -181,7 +186,7 @@ function get_bookmarks($args = '') {
        }
 
        if ( ! empty($search) ) {
-               $search = like_escape($search);
+               $search = esc_sql( like_escape( $search ) );
                $search = " AND ( (link_url LIKE '%$search%') OR (link_name LIKE '%$search%') OR (link_description LIKE '%$search%') ) ";
        }