Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4057149
populateHomeDB.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
populateHomeDB.php
View Options
<?php
namespace
MediaWiki\Extension\CentralAuth\Maintenance
;
// @codeCoverageIgnoreStart
$IP
=
getenv
(
'MW_INSTALL_PATH'
);
if
(
$IP
===
false
)
{
$IP
=
__DIR__
.
'/../../..'
;
}
require_once
"$IP/maintenance/Maintenance.php"
;
// @codeCoverageIgnoreEnd
use
MediaWiki\Extension\CentralAuth\CentralAuthServices
;
use
MediaWiki\Extension\CentralAuth\User\CentralAuthUser
;
use
MediaWiki\Maintenance\Maintenance
;
use
Wikimedia\Rdbms\IDBAccessObject
;
class
PopulateHomeDB
extends
Maintenance
{
public
function
__construct
()
{
parent
::
__construct
();
$this
->
requireExtension
(
'CentralAuth'
);
$this
->
addDescription
(
'Populate the globaluser.gu_home_db field'
);
$this
->
setBatchSize
(
500
);
}
public
function
execute
()
{
$db
=
CentralAuthServices
::
getDatabaseManager
()->
getCentralReplicaDB
();
$conds
=
[];
$count
=
0
;
do
{
$result
=
$db
->
newSelectQueryBuilder
()
->
select
(
'gu_name'
)
->
from
(
'globaluser'
)
->
where
(
$conds
)
->
andWhere
(
$db
->
expr
(
'gu_home_db'
,
'='
,
null
)->
or
(
'gu_home_db'
,
'='
,
''
)
)
->
orderBy
(
'gu_name'
)
->
limit
(
$this
->
mBatchSize
)
->
caller
(
__METHOD__
)
->
fetchResultSet
();
foreach
(
$result
as
$row
)
{
$central
=
new
CentralAuthUser
(
$row
->
gu_name
,
IDBAccessObject
::
READ_LATEST
);
$central
->
mStateDirty
=
true
;
$central
->
saveSettings
();
$count
++;
}
$this
->
output
(
"$count
\n
"
);
$this
->
waitForReplication
();
if
(
$result
->
numRows
()
<
$this
->
mBatchSize
)
{
break
;
}
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable
$conds
=
[
$db
->
expr
(
'gu_name'
,
'>'
,
$row
->
gu_name
)
];
}
while
(
true
);
$this
->
output
(
"done.
\n
"
);
}
}
// @codeCoverageIgnoreStart
$maintClass
=
PopulateHomeDB
::
class
;
require_once
RUN_MAINTENANCE_IF_MAIN
;
// @codeCoverageIgnoreEnd
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 16 2026, 03:52 (13 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
97/34/3800b0ee49e1df3803b362979d72
Default Alt Text
populateHomeDB.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment