MediaWiki 1.42.1
pageExists.php
Go to the documentation of this file.
1<?php
22require_once __DIR__ . '/Maintenance.php';
23
25
29class PageExists extends Maintenance {
30 public function __construct() {
31 parent::__construct();
32 $this->addDescription( 'Report whether a specific page exists' );
33 $this->addArg( 'title', 'Page title to check whether it exists' );
34 }
35
36 public function execute() {
37 $titleArg = $this->getArg( 0 );
38 $title = Title::newFromText( $titleArg );
39 $pageExists = $title && $title->exists();
40
41 if ( $pageExists ) {
42 $text = "{$title} exists.\n";
43 } else {
44 $text = "{$titleArg} doesn't exist.\n";
45 }
46 $this->output( $text );
47 return $pageExists;
48 }
49}
50
51$maintClass = PageExists::class;
52require_once RUN_MAINTENANCE_IF_MAIN;
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.
output( $out, $channel=null)
Throw some output to the user.
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
Represents a title within MediaWiki.
Definition Title.php:78
__construct()
Default constructor.
execute()
Do the actual work.
$maintClass