MediaWiki
REL1_40
dumpLinks.php
Go to the documentation of this file.
1
<?php
33
require_once __DIR__ .
'/Maintenance.php'
;
34
35
use
MediaWiki\Title\Title
;
36
42
class
DumpLinks
extends
Maintenance
{
43
public
function
__construct
() {
44
parent::__construct();
45
$this->
addDescription
(
'Quick demo hack to generate a plaintext link dump'
);
46
}
47
48
public
function
execute
() {
49
$dbr
= $this->
getDB
(
DB_REPLICA
);
50
51
$result =
$dbr
->newSelectQueryBuilder()
52
->select( [
53
'page_id'
,
54
'page_namespace'
,
55
'page_title'
,
56
'pl_namespace'
,
57
'pl_title'
58
] )
59
->from(
'page'
)
60
->join(
'pagelinks'
,
null
, [
'page_id=pl_from'
] )
61
->orderBy(
'page_id'
)
62
->caller( __METHOD__ )
63
->fetchResultSet();
64
65
$lastPage =
null
;
66
foreach
( $result as $row ) {
67
if
( $lastPage != $row->page_id ) {
68
if
( $lastPage !==
null
) {
69
$this->
output
(
"\n"
);
70
}
71
$page = Title::makeTitle( $row->page_namespace, $row->page_title );
72
$this->
output
( $page->getPrefixedURL() );
73
$lastPage = $row->page_id;
74
}
75
$link = Title::makeTitle( $row->pl_namespace, $row->pl_title );
76
$this->
output
(
" "
. $link->getPrefixedURL() );
77
}
78
if
( $lastPage !==
null
) {
79
$this->
output
(
"\n"
);
80
}
81
}
82
}
83
84
$maintClass
= DumpLinks::class;
85
require_once RUN_MAINTENANCE_IF_MAIN;
getDB
getDB()
DumpLinks
Maintenance script that generates a plaintext link dump.
Definition
dumpLinks.php:42
DumpLinks\__construct
__construct()
Default constructor.
Definition
dumpLinks.php:43
DumpLinks\execute
execute()
Do the actual work.
Definition
dumpLinks.php:48
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:466
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:340
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:82
$maintClass
$maintClass
Definition
dumpLinks.php:84
DB_REPLICA
const DB_REPLICA
Definition
defines.php:26
$dbr
$dbr
Definition
testCompression.php:55
maintenance
dumpLinks.php
Generated on Thu Jun 27 2024 14:04:57 for MediaWiki by
1.10.0