MediaWiki fundraising/REL1_35
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 $code = 0;
40 if ( $pageExists ) {
41 $text = "{$title} exists.\n";
42 } else {
43 $text = "{$titleArg} doesn't exist.\n";
44 $code = 1;
45 }
46 $this->output( $text );
47 exit( $code );
48 }
49}
50
51$maintClass = PageExists::class;
52require_once RUN_MAINTENANCE_IF_MAIN;
const 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