diff --git a/lib/blogs.php b/lib/blogs.php index 69787759c1bd51ee64e8557338e1a5422f46e5de..cf18bd3d1d440fc37ba8bea407f9bbd8fabd7c7c 100644 --- a/lib/blogs.php +++ b/lib/blogs.php @@ -29,6 +29,7 @@ function noblogs_get_blog($blogname) { function noblogs_get_backend_for_blog($blog_id) { global $wpdb; global $r2db_hash_map; + global $wpdb_reverse_backend_map; // Compatibility shim between old/new r2db. $hash_map = $r2db_hash_map; @@ -36,16 +37,9 @@ function noblogs_get_backend_for_blog($blog_id) { $hash_map = $wpdb->hash_map; } - // Create a temporary hash object just to load the backends - // (we cannot use the map in $wpdb because it doesn't have the - // backend array anymore). - $hashmap = new Flexihash(null, R2DB_FLEXIHASH_REPLICAS); - $reversemap = noblogs_load_backends($hashmap); - - // Lookup the blog ID using the $wpdb hash just to be safe (though - // we should get an identical result using $hashmap). + // Lookup the blog ID. $lookup = $hash_map->lookup($blog_id); - $backend = $reversemap[$lookup]; + $backend = $wpdb_reverse_backend_map[$lookup]; // Be nice and split the database host into 'host' and 'port' elements. $result = array();