Make WordPress Core


Ignore:
Timestamp:
10/01/2012 06:03:23 PM (12 years ago)
Author:
ryan
Message:
  • Register blog-id-cache group as global
  • Introduce clean_blog_cache() so we can run it independently of refresh_blog_details() which assumes the blog still exists and get_blog_details() can be called.
  • Don't db escape cache keys in get_blog_id_from_url()
  • prepare() the query in get_blog_id_from_url()
  • Return 0 for all failures in get_blog_id_from_url()
  • clean_blog_cache() after dropping tables in wpmu_delete_blog() to make sure the cache is for real cleaned.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-functions.php

    r22065 r22092  
    333333 * @param string $domain
    334334 * @param string $path Optional. Not required for subdomain installations.
    335  * @return int
     335 * @return int 0 if no blog found, otherwise the ID of the matching blog
    336336 */
    337337function get_blog_id_from_url( $domain, $path = '/' ) {
    338338    global $wpdb;
    339339
    340     $domain = strtolower( $wpdb->escape( $domain ) );
    341     $path = strtolower( $wpdb->escape( $path ) );
     340    $domain = strtolower( $domain );
     341    $path = strtolower( $path );
    342342    $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
    343343
    344     if ( $id == -1 ) { // blog does not exist
     344    if ( $id == -1 ) // blog does not exist
    345345        return 0;
    346     } elseif ( $id ) {
    347         return (int)$id;
    348     }
    349 
    350     $id = $wpdb->get_var( "SELECT blog_id FROM $wpdb->blogs WHERE domain = '$domain' and path = '$path' /* get_blog_id_from_url */" );
    351 
    352     if ( !$id ) {
     346    elseif ( $id )
     347        return (int) $id;
     348
     349    $id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s and path = %s /* get_blog_id_from_url */", $domain, $path ) );
     350
     351    if ( ! $id ) {
    353352        wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' );
    354         return false;
    355     }
     353        return 0;
     354    }
     355
    356356    wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' );
    357357
Note: See TracChangeset for help on using the changeset viewer.