MediaWiki
REL1_39
dumpLinks.php
Go to the documentation of this file.
1
<?php
33
require_once __DIR__ .
'/Maintenance.php'
;
34
40
class
DumpLinks
extends
Maintenance
{
41
public
function
__construct
() {
42
parent::__construct();
43
$this->
addDescription
(
'Quick demo hack to generate a plaintext link dump'
);
44
}
45
46
public
function
execute
() {
47
$dbr
= $this->
getDB
(
DB_REPLICA
);
48
49
$result =
$dbr
->newSelectQueryBuilder()
50
->select( [
51
'page_id'
,
52
'page_namespace'
,
53
'page_title'
,
54
'pl_namespace'
,
55
'pl_title'
56
] )
57
->from(
'page'
)
58
->join(
'pagelinks'
,
null
, [
'page_id=pl_from'
] )
59
->orderBy(
'page_id'
)
60
->caller( __METHOD__ )
61
->fetchResultSet();
62
63
$lastPage =
null
;
64
foreach
( $result as $row ) {
65
if
( $lastPage != $row->page_id ) {
66
if
( $lastPage !==
null
) {
67
$this->
output
(
"\n"
);
68
}
69
$page = Title::makeTitle( $row->page_namespace, $row->page_title );
70
$this->
output
( $page->getPrefixedURL() );
71
$lastPage = $row->page_id;
72
}
73
$link = Title::makeTitle( $row->pl_namespace, $row->pl_title );
74
$this->
output
(
" "
. $link->getPrefixedURL() );
75
}
76
if
( $lastPage !==
null
) {
77
$this->
output
(
"\n"
);
78
}
79
}
80
}
81
82
$maintClass
= DumpLinks::class;
83
require_once RUN_MAINTENANCE_IF_MAIN;
getDB
getDB()
DumpLinks
Maintenance script that generates a plaintext link dump.
Definition
dumpLinks.php:40
DumpLinks\__construct
__construct()
Default constructor.
Definition
dumpLinks.php:41
DumpLinks\execute
execute()
Do the actual work.
Definition
dumpLinks.php:46
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition
Maintenance.php:66
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition
Maintenance.php:443
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:319
$maintClass
$maintClass
Definition
dumpLinks.php:82
DB_REPLICA
const DB_REPLICA
Definition
defines.php:26
$dbr
$dbr
Definition
testCompression.php:54
maintenance
dumpLinks.php
Generated on Mon Dec 23 2024 06:25:34 for MediaWiki by
1.10.0