MediaWiki
REL1_34
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
$result =
$dbr
->select( [
'pagelinks'
,
'page'
],
49
[
50
'page_id'
,
51
'page_namespace'
,
52
'page_title'
,
53
'pl_namespace'
,
54
'pl_title'
],
55
[
'page_id=pl_from'
],
56
__METHOD__,
57
[
'ORDER BY'
=>
'page_id'
] );
58
59
$lastPage =
null
;
60
foreach
( $result as $row ) {
61
if
( $lastPage != $row->page_id ) {
62
if
( $lastPage !==
null
) {
63
$this->
output
(
"\n"
);
64
}
65
$page = Title::makeTitle( $row->page_namespace, $row->page_title );
66
$this->
output
( $page->getPrefixedURL() );
67
$lastPage = $row->page_id;
68
}
69
$link = Title::makeTitle( $row->pl_namespace, $row->pl_title );
70
$this->
output
(
" "
. $link->getPrefixedURL() );
71
}
72
if
( $lastPage !==
null
) {
73
$this->
output
(
"\n"
);
74
}
75
}
76
}
77
78
$maintClass
= DumpLinks::class;
79
require_once
RUN_MAINTENANCE_IF_MAIN
;
getDB
getDB()
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition
Maintenance.php:39
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:82
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition
Maintenance.php:453
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:348
$maintClass
$maintClass
Definition
dumpLinks.php:78
DB_REPLICA
const DB_REPLICA
Definition
defines.php:25
$dbr
$dbr
Definition
testCompression.php:50
maintenance
dumpLinks.php
Generated on Mon Nov 25 2024 16:06:23 for MediaWiki by
1.10.0