MediaWiki
master
pageExists.php
Go to the documentation of this file.
1
<?php
22
// @codeCoverageIgnoreStart
23
require_once __DIR__ .
'/Maintenance.php'
;
24
// @codeCoverageIgnoreEnd
25
26
use
MediaWiki\Maintenance\Maintenance
;
27
use
MediaWiki\Title\Title
;
28
32
class
PageExists
extends
Maintenance
{
33
public
function
__construct
() {
34
parent::__construct();
35
$this->
addDescription
(
'Report whether a specific page exists'
);
36
$this->
addArg
(
'title'
,
'Page title to check whether it exists'
);
37
}
38
40
public
function
execute
() {
41
$titleArg = $this->
getArg
( 0 );
42
$title = Title::newFromText( $titleArg );
43
$pageExists = $title && $title->exists();
44
45
if
( $pageExists ) {
46
$text =
"{$title} exists.\n"
;
47
}
else
{
48
$text =
"{$titleArg} doesn't exist.\n"
;
49
}
50
$this->
output
( $text );
51
return
$pageExists;
52
}
53
}
54
55
// @codeCoverageIgnoreStart
56
$maintClass
= PageExists::class;
57
require_once RUN_MAINTENANCE_IF_MAIN;
58
// @codeCoverageIgnoreEnd
MediaWiki\Maintenance\Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition
Maintenance.php:78
MediaWiki\Maintenance\Maintenance\addArg
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
Definition
Maintenance.php:318
MediaWiki\Maintenance\Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition
Maintenance.php:365
MediaWiki\Maintenance\Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition
Maintenance.php:493
MediaWiki\Maintenance\Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:343
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:78
PageExists
Definition
pageExists.php:32
PageExists\__construct
__construct()
Default constructor.
Definition
pageExists.php:33
PageExists\execute
execute()
Do the actual work.All child classes will need to implement thisbool|null|void True for success,...
Definition
pageExists.php:40
$maintClass
$maintClass
Definition
pageExists.php:56
maintenance
pageExists.php
Generated on Sun May 18 2025 00:27:45 for MediaWiki by
1.10.0