MediaWiki REL1_39
pageExists.php
Go to the documentation of this file.
1<?php
22require_once __DIR__ . '/Maintenance.php';
23
27class PageExists extends Maintenance {
28 public function __construct() {
29 parent::__construct();
30 $this->addDescription( 'Report whether a specific page exists' );
31 $this->addArg( 'title', 'Page title to check whether it exists' );
32 }
33
34 public function execute() {
35 $titleArg = $this->getArg( 0 );
36 $title = Title::newFromText( $titleArg );
37 $pageExists = $title && $title->exists();
38
39 if ( $pageExists ) {
40 $text = "{$title} exists.\n";
41 } else {
42 $text = "{$titleArg} doesn't exist.\n";
43 }
44 $this->output( $text );
45 return $pageExists;
46 }
47}
48
49$maintClass = PageExists::class;
50require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
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.
__construct()
Default constructor.
execute()
Do the actual work.
$maintClass