Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
noblogs-cli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Noblogs
noblogs-cli
Commits
c92e382f
Commit
c92e382f
authored
3 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Do not instantiate a second Flexihash just to find the backend name
Fixes issue
#3
.
parent
2db59e49
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/blogs.php
+3
-9
3 additions, 9 deletions
lib/blogs.php
with
3 additions
and
9 deletions
lib/blogs.php
+
3
−
9
View file @
c92e382f
...
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment