Skip to content
Snippets Groups Projects
Commit 7c857273 authored by ale's avatar ale
Browse files

Use our own global variable for the FlexiHash instance

Instead of using an attribute inside $wpdb.
parent 5b798c39
Branches
Tags
No related merge requests found
......@@ -3,17 +3,17 @@
require_once(dirname(__FILE__) . '/flexihash.php');
require_once( ABSPATH . 'wp-config.php' );
$wpdb->hash_map = new Flexihash(null, R2DB_FLEXIHASH_REPLICAS);
$r2db_hash_map = new Flexihash(null, R2DB_FLEXIHASH_REPLICAS);
/* Hashing function to map blogs to databases.
*
* Implements a consistent hashing scheme using Flexihash.
*/
function noblogs_db_callback($query, $wpdb) {
$wpdb_hash = $wpdb->hash_map;
global $r2db_hash_map;
if (preg_match("/^{$wpdb->base_prefix}(\d+)_/", $wpdb->table, $matches)) {
$blog_id = $matches[1];
return $wpdb_hash->lookup($blog_id);
return $r2db_hash_map->lookup($blog_id);
}
}
$wpdb->add_callback('noblogs_db_callback');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment