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
0231e8c8
Commit
0231e8c8
authored
4 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Update code for new $r2db_hash_map global
parent
66c0a7a6
No related branches found
No related tags found
1 merge request
!1
Update code for new $r2db_hash_map global
Pipeline
#12521
passed
4 years ago
Stage: build_pkgsrc
Stage: build_pkg
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/generate-noblogsmv-map
+5
-1
5 additions, 1 deletion
bin/generate-noblogsmv-map
lib/blogs.php
+16
-3
16 additions, 3 deletions
lib/blogs.php
with
21 additions
and
4 deletions
bin/generate-noblogsmv-map
+
5
−
1
View file @
0231e8c8
...
...
@@ -134,7 +134,11 @@ function backend_to_http_endpoint($backend) {
// Print the blog -> backend map.
function
generate_map
()
{
global
$wpdb
;
$wpdb_hash
=
&
$wpdb
->
hash_map
;
global
$r2db_hash_map
;
$wpdb_hash
=
$r2db_hash_map
;
if
(
!
$wpdb_hash
)
{
$wpdb_hash
=
&
$wpdb
->
hash_map
;
}
$blogs
=
get_blogs
();
...
...
This diff is collapsed.
Click to expand it.
lib/blogs.php
+
16
−
3
View file @
0231e8c8
...
...
@@ -28,6 +28,13 @@ function noblogs_get_blog($blogname) {
// Return the database connection information associated with a blog.
function
noblogs_get_backend_for_blog
(
$blog_id
)
{
global
$wpdb
;
global
$r2db_hash_map
;
// Compatibility shim between old/new r2db.
$hash_map
=
$r2db_hash_map
;
if
(
!
$hash_map
)
{
$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
...
...
@@ -37,7 +44,7 @@ function noblogs_get_backend_for_blog($blog_id) {
// Lookup the blog ID using the $wpdb hash just to be safe (though
// we should get an identical result using $hashmap).
$lookup
=
$
wpdb
->
hash_map
->
lookup
(
$blog_id
);
$lookup
=
$hash_map
->
lookup
(
$blog_id
);
$backend
=
$reversemap
[
$lookup
];
// Be nice and split the database host into 'host' and 'port' elements.
...
...
@@ -57,14 +64,20 @@ function noblogs_get_backend_for_blog($blog_id) {
// Return the full backend -> blogs map.
function
noblogs_get_backend_map
()
{
global
$wpdb
;
$wpdb_hash
=
&
$wpdb
->
hash_map
;
global
$r2db_hash_map
;
// Compatibility shim between old/new r2db.
$hash_map
=
$r2db_hash_map
;
if
(
!
$hash_map
)
{
$hash_map
=
$wpdb
->
hash_map
;
}
$blogs
=
noblogs_get_blogs
();
$backend_map
=
array
();
foreach
(
$blogs
as
$blog
)
{
$blog_id
=
$blog
->
blog_id
;
$backend_id
=
$
wpdb_
hash
->
lookup
(
$blog_id
);
$backend_id
=
$hash
_map
->
lookup
(
$blog_id
);
if
(
!
array_key_exists
(
$backend_id
,
$backend_map
))
{
$backend_map
[
$backend_id
]
=
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