Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P2521
listUnattached.php
Active
Public
Actions
Authored by
Legoktm
on Jan 22 2016, 9:29 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Tags
None
Referenced Files
F3270156: listUnattached.php
Feb 24 2016, 5:27 AM
2016-02-24 05:27:50 (UTC+0)
Subscribers
Liuxinyu970226
<?php
$IP
=
getenv
(
'MW_INSTALL_PATH'
);
if
(
$IP
===
false
)
{
$IP
=
__DIR__
.
'/../../..'
;
}
require_once
(
"$IP/maintenance/Maintenance.php"
);
/**
* Lists all unattached accounts in a format friendly for migrateAccount.php
*/
class
ListUnattached
extends
Maintenance
{
private
$lName
=
''
;
private
$lWiki
=
''
;
public
function
__construct
()
{
parent
::
__construct
();
$this
->
addOption
(
'wiki'
,
'Output wiki name'
,
false
,
false
);
$this
->
setBatchSize
(
1000
);
}
/**
* Fetches unattached accounts and attempts to continue.
*
* @return ResultWrapper
*/
private
function
doQuery
()
{
$dbr
=
CentralAuthUtils
::
getCentralSlaveDB
();
$rows
=
$dbr
->
select
(
array
(
'localnames'
,
'localuser'
),
array
(
'ln_name AS name'
,
'ln_wiki AS wiki'
),
array
(
$dbr
->
makeList
(
array
(
'ln_name > '
.
$dbr
->
addQuotes
(
$this
->
lName
),
'ln_name = '
.
$dbr
->
addQuotes
(
$this
->
lName
)
.
' AND ln_wiki > '
.
$dbr
->
addQuotes
(
$this
->
lWiki
)
),
LIST_OR
),
'lu_attached_method IS NULL'
),
__METHOD__
,
array
(
'LIMIT'
=>
$this
->
mBatchSize
,
'ORDER BY'
=>
array
(
'ln_name'
,
'ln_wiki'
),
),
array
(
'localuser'
=>
array
(
'LEFT JOIN'
,
'ln_name=lu_name AND ln_wiki=lu_wiki'
)
)
);
return
$rows
;
}
public
function
execute
()
{
$outputWiki
=
$this
->
hasOption
(
'wiki'
)
&&
false
;
do
{
$rows
=
$this
->
doQuery
();
foreach
(
$rows
as
$row
)
{
$this
->
lName
=
$row
->
name
;
$this
->
lWiki
=
$row
->
wiki
;
if
(
$outputWiki
)
{
$this
->
output
(
"$row->name
\t
$row->wiki
\n
"
);
}
else
{
$this
->
output
(
"$row->name
\n
"
);
}
}
}
while
(
$rows
->
numRows
()
!==
0
);
}
}
$maintClass
=
'ListUnattached'
;
require_once
RUN_MAINTENANCE_IF_MAIN
;
Event Timeline
Legoktm
changed the title of this paste from untitled to
listUnattached.php
.
Jan 22 2016, 9:29 PM
2016-01-22 21:29:29 (UTC+0)
Legoktm
edited the content of this paste.
(Show Details)
Legoktm
mentioned this in
T124476: Commit listUnattached.php script to CentralAuth repo
.
Liuxinyu970226
updated the paste's language from
autodetect
to
php
.
Dec 31 2016, 1:04 AM
2016-12-31 01:04:16 (UTC+0)
Liuxinyu970226
subscribed.
Noe
mentioned this in
T249447: Correct gender display for qualifiers
.
Apr 5 2020, 1:53 PM
2020-04-05 13:53:09 (UTC+0)
Log In to Comment