MediaWiki
REL1_34
checkBadRedirects.php
Go to the documentation of this file.
1
<?php
24
require_once __DIR__ .
'/Maintenance.php'
;
25
31
class
CheckBadRedirects
extends
Maintenance
{
32
public
function
__construct
() {
33
parent::__construct();
34
$this->
addDescription
(
'Check for bad redirects'
);
35
}
36
37
public
function
execute
() {
38
$this->
output
(
"Fetching redirects...\n"
);
39
$dbr
= $this->
getDB
(
DB_REPLICA
);
40
$result =
$dbr
->select(
41
[
'page'
],
42
[
'page_namespace'
,
'page_title'
,
'page_latest'
],
43
[
'page_is_redirect'
=> 1 ] );
44
45
$count = $result->numRows();
46
$this->
output
(
"Found $count redirects.\n"
.
47
"Checking for bad redirects:\n\n"
);
48
49
foreach
( $result as $row ) {
50
$title
= Title::makeTitle( $row->page_namespace, $row->page_title );
51
$rev =
Revision::newFromId
( $row->page_latest );
52
if
( $rev ) {
53
$target = $rev->getContent()->getRedirectTarget();
54
if
( !$target ) {
55
$this->
output
(
$title
->getPrefixedText() .
"\n"
);
56
}
57
}
58
}
59
$this->
output
(
"\nDone.\n"
);
60
}
61
}
62
63
$maintClass
= CheckBadRedirects::class;
64
require_once
RUN_MAINTENANCE_IF_MAIN
;
getDB
getDB()
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition
Maintenance.php:39
$maintClass
$maintClass
Definition
checkBadRedirects.php:63
CheckBadRedirects
Maintenance script to check that pages marked as being redirects really are.
Definition
checkBadRedirects.php:31
CheckBadRedirects\execute
execute()
Do the actual work.
Definition
checkBadRedirects.php:37
CheckBadRedirects\__construct
__construct()
Default constructor.
Definition
checkBadRedirects.php:32
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
Revision\newFromId
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition
Revision.php:119
DB_REPLICA
const DB_REPLICA
Definition
defines.php:25
$dbr
$dbr
Definition
testCompression.php:50
$title
$title
Definition
testCompression.php:34
maintenance
checkBadRedirects.php
Generated on Fri Apr 5 2024 23:11:05 for MediaWiki by
1.9.8