MediaWiki master
pageExists.php
Go to the documentation of this file.
1<?php
22// @codeCoverageIgnoreStart
23require_once __DIR__ . '/Maintenance.php';
24// @codeCoverageIgnoreEnd
25
28
32class 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;
57require_once RUN_MAINTENANCE_IF_MAIN;
58// @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:78
__construct()
Default constructor.
execute()
Do the actual work.All child classes will need to implement thisbool|null|void True for success,...
$maintClass