MediaWiki
master
pageExists.php
Go to the documentation of this file.
1
<?php
8
// @codeCoverageIgnoreStart
9
require_once __DIR__ .
'/Maintenance.php'
;
10
// @codeCoverageIgnoreEnd
11
12
use
MediaWiki\Maintenance\Maintenance
;
13
use
MediaWiki\Title\Title
;
14
18
class
PageExists
extends
Maintenance
{
19
public
function
__construct
() {
20
parent::__construct();
21
$this->
addDescription
(
'Report whether a specific page exists'
);
22
$this->
addArg
(
'title'
,
'Page title to check whether it exists'
);
23
}
24
26
public
function
execute
() {
27
$titleArg = $this->
getArg
( 0 );
28
$title = Title::newFromText( $titleArg );
29
$pageExists = $title && $title->exists();
30
31
if
( $pageExists ) {
32
$text =
"{$title} exists.\n"
;
33
}
else
{
34
$text =
"{$titleArg} doesn't exist.\n"
;
35
}
36
$this->
output
( $text );
37
return
$pageExists;
38
}
39
}
40
41
// @codeCoverageIgnoreStart
42
$maintClass
= PageExists::class;
43
require_once RUN_MAINTENANCE_IF_MAIN;
44
// @codeCoverageIgnoreEnd
MediaWiki\Maintenance\Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition
Maintenance.php:65
MediaWiki\Maintenance\Maintenance\addArg
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
Definition
Maintenance.php:311
MediaWiki\Maintenance\Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition
Maintenance.php:358
MediaWiki\Maintenance\Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition
Maintenance.php:486
MediaWiki\Maintenance\Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:336
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:69
PageExists
Definition
pageExists.php:18
PageExists\__construct
__construct()
Default constructor.
Definition
pageExists.php:19
PageExists\execute
execute()
Do the actual work.All child classes will need to implement thisbool|null|void True for success,...
Definition
pageExists.php:26
$maintClass
$maintClass
Definition
pageExists.php:42
maintenance
pageExists.php
Generated on Wed Feb 11 2026 05:42:57 for MediaWiki by
1.10.0