From 7c857273798e217620ad0fb2a63ea7a1c0c6aae9 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Wed, 17 Feb 2021 11:14:44 +0000
Subject: [PATCH] Use our own global variable for the FlexiHash instance

Instead of using an attribute inside $wpdb.
---
 db-hash.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/db-hash.php b/db-hash.php
index 8938929..70349ec 100644
--- a/db-hash.php
+++ b/db-hash.php
@@ -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');
-- 
GitLab