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
39 public function execute() {
40 $titleArg = $this->getArg( 0 );
41 $title = Title::newFromText( $titleArg );
42 $pageExists = $title && $title->exists();
43
44 if ( $pageExists ) {
45 $text = "{$title} exists.\n";
46 } else {
47 $text = "{$titleArg} doesn't exist.\n";
48 }
49 $this->output( $text );
50 return $pageExists;
51 }
52}
53
54// @codeCoverageIgnoreStart
55$maintClass = PageExists::class;
56require_once RUN_MAINTENANCE_IF_MAIN;
57// @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.
$maintClass