MediaWiki fundraising/REL1_35
TestCrash.php
Go to the documentation of this file.
1#!/usr/bin/env php
2<?php
3// XXX only deployed for a quick debuggery party
4
5$IP = getenv( 'MW_INSTALL_PATH' );
6if ( $IP === false ) {
7 $IP = __DIR__ . '/../../../..';
8}
9
10// If you get errors on this next line, set (and export) your MW_INSTALL_PATH var.
11require_once "$IP/maintenance/Maintenance.php";
12
13class TestCrash extends Maintenance {
14 public function __construct() {
15 parent::__construct();
16
17 $this->requireExtension( 'Donation Interface' );
18
19 $this->addOption( 'error', 'Yell ->error and exit' );
20 $this->addOption( 'exception', 'Crash with an exception' );
21 $this->addOption( 'fatal', 'Do something unexpected' );
22 }
23
24 public function execute() {
25 if ( $this->getOption( 'error' ) ) {
26 $this->error( 'CRASHTEST: error', true );
27 }
28 if ( $this->getOption( 'exception' ) ) {
29 throw new Exception( 'CRASHTEST: uncaught exception' );
30 }
31 if ( $this->getOption( 'fatal' ) ) {
32 $this->error( 'CRASHTEST: fatal' );
33 $everything_and_nothing = FOO::BAR();
34 }
35
36 $this->error( 'CRASHTEST: should not reach this line.' );
37 }
38}
39
40$maintClass = TestCrash::class;
41require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
$IP
Definition TestCrash.php:5
$maintClass
Definition TestCrash.php:40
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
execute()
Do the actual work.
Definition TestCrash.php:24
__construct()
Default constructor.
Definition TestCrash.php:14