addDescription( 'Purge page.' ); $this->addOption( 'skip-exists-check', 'Skip page existence check', false, false ); } public function execute() { $stdin = $this->getStdin(); while ( !feof( $stdin ) ) { $title = trim( fgets( $stdin ) ); if ( $title != '' ) { $this->purge( $title ); } } } private function purge( $titleText ) { $title = Title::newFromText( $titleText ); if ( is_null( $title ) ) { $this->error( 'Invalid page title' ); return; } $page = WikiPage::factory( $title ); if ( is_null( $page ) ) { $this->error( "Could not instantiate page object" ); return; } if ( !$this->getOption( 'skip-exists-check' ) && !$page->exists() ) { $this->error( "Page doesn't exist" ); return; } if ( $page->doPurge() ) { $this->output( "Purged {$titleText}\n" ); } else { $this->error( "Purge failed for {$titleText}" ); } } } $maintClass = PurgePage::class; require_once RUN_MAINTENANCE_IF_MAIN;