From 9261edddf161b186ed8bf6245c6fe5baa88d5068 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Thu, 25 Feb 2021 11:14:20 +0000 Subject: [PATCH] Revert "Add support for github.com/stuttter/ludicrousdb" This reverts commit 7cf52a2ab5cc47301d94f7c290a79d77454e38ec. It turns out that the LudicrousDB documentation is slightly misleading, and the 'dataset' callback actually receives exactly the same arguments as with HyperDB, so there is no need for custom switching code. --- db-backends.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/db-backends.php b/db-backends.php index b6df992..ace5b2a 100644 --- a/db-backends.php +++ b/db-backends.php @@ -10,7 +10,7 @@ $r2db_hash_map = new Flexihash(null, R2DB_FLEXIHASH_REPLICAS); * * Implements a consistent hashing scheme using Flexihash. */ -function noblogs_hyperdb_callback($query, $wpdb) { +function noblogs_db_callback($query, $wpdb) { global $r2db_hash_map; if (preg_match("/^{$wpdb->base_prefix}(\d+)_/", $wpdb->table, $matches)) { $blog_id = $matches[1]; @@ -18,22 +18,7 @@ function noblogs_hyperdb_callback($query, $wpdb) { } } -/* Same as above but with a slightly different function - signature for https://github.com/stuttter/ludicrousdb */ -function noblogs_ludicrousdb_callback($table, $wpdb) { - global $r2db_hash_map; - if (preg_match("/^{$wpdb->base_prefix}(\d+)_/", $table, $matches)) { - $blog_id = $matches[1]; - return $r2db_hash_map->lookup($blog_id); - } - return "global"; -} - -if (defined('R2DB_USE_LUDICROUSDB')) { - $wpdb->add_callback('noblogs_ludicrousdb_callback'); -} else { - $wpdb->add_callback('noblogs_hyperdb_callback'); -} +$wpdb->add_callback('noblogs_db_callback'); /* Load backend shards and add them to FlexiHash / $wpdb. */ function noblogs_load_backends() { -- GitLab