MediaWiki master
pageExists.php
Go to the documentation of this file.
1<?php
8// @codeCoverageIgnoreStart
9require_once __DIR__ . '/Maintenance.php';
10// @codeCoverageIgnoreEnd
11
14
18class 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;
43require_once RUN_MAINTENANCE_IF_MAIN;
44// @codeCoverageIgnoreEnd
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
Represents a title within MediaWiki.
Definition Title.php:69
__construct()
Default constructor.
execute()
Do the actual work.All child classes will need to implement thisbool|null|void True for success,...
$maintClass