Index: branches/maintenance-work/maintenance/Maintenance.php |
— | — | @@ -306,8 +306,11 @@ |
307 | 307 | $this->output( $this->mDescription . "\n" ); |
308 | 308 | } |
309 | 309 | $this->output( "\nUsage: php " . $this->mSelf . " [--" . |
310 | | - implode( array_keys( $this->mParams ), "|--" ) . "] <" . |
311 | | - implode( $this->mArgList, "> <" ) . ">\n" ); |
| 310 | + implode( array_keys( $this->mParams ), "|--" ) . "]" ); |
| 311 | + if( $this->mArgList ) { |
| 312 | + $this->output( " <" . implode( $this->mArgList, "> <" ) . ">" ); |
| 313 | + } |
| 314 | + $this->output( "\n" ); |
312 | 315 | foreach( $this->mParams as $par => $info ) { |
313 | 316 | $this->output( "\t$par : " . $info['desc'] . "\n" ); |
314 | 317 | } |
Index: branches/maintenance-work/maintenance/eval.php |
— | — | @@ -16,57 +16,66 @@ |
17 | 17 | * @ingroup Maintenance |
18 | 18 | */ |
19 | 19 | |
20 | | -$wgUseNormalUser = (bool)getenv('MW_WIKIUSER'); |
| 20 | +require_once( "Maintenance.php" ); |
21 | 21 | |
22 | | -$optionsWithArgs = array( 'd' ); |
| 22 | +class EvalPrompt extends Maintenance { |
23 | 23 | |
24 | | -/** */ |
25 | | -require_once( "commandLine.inc" ); |
26 | | - |
27 | | -if ( isset( $options['d'] ) ) { |
28 | | - $d = $options['d']; |
29 | | - if ( $d > 0 ) { |
30 | | - $wgDebugLogFile = '/dev/stdout'; |
| 24 | + public function __construct() { |
| 25 | + parent::__construct(); |
| 26 | + $this->mDescription = "This script lets a command-line user start up the wiki engine and then poke\n" . |
| 27 | + "about by issuing PHP commands directly."; |
| 28 | + $this->addParam( 'd', "Enable MediaWiki debug output", false, true ); |
31 | 29 | } |
32 | | - if ( $d > 1 ) { |
33 | | - $lb = wfGetLB(); |
34 | | - foreach ( $lb->mServers as $i => $server ) { |
35 | | - $lb->mServers[$i]['flags'] |= DBO_DEBUG; |
| 30 | + |
| 31 | + public function execute() { |
| 32 | + global $wgUseNormalUser; |
| 33 | + $wgUseNormalUser = (bool)getenv('MW_WIKIUSER'); |
| 34 | + if ( $this->hasOption('d') ) { |
| 35 | + $d = $this->getOption('d'); |
| 36 | + if ( $d > 0 ) { |
| 37 | + $wgDebugLogFile = '/dev/stdout'; |
| 38 | + } |
| 39 | + if ( $d > 1 ) { |
| 40 | + $lb = wfGetLB(); |
| 41 | + foreach ( $lb->mServers as $i => $server ) { |
| 42 | + $lb->mServers[$i]['flags'] |= DBO_DEBUG; |
| 43 | + } |
| 44 | + } |
| 45 | + if ( $d > 2 ) { |
| 46 | + $wgDebugFunctionEntry = true; |
| 47 | + } |
36 | 48 | } |
| 49 | + |
| 50 | + if ( function_exists( 'readline_add_history' ) |
| 51 | + && function_exists( 'posix_isatty' ) && posix_isatty( 0 /*STDIN*/ ) ) |
| 52 | + { |
| 53 | + $useReadline = true; |
| 54 | + } else { |
| 55 | + $useReadline = false; |
| 56 | + } |
| 57 | + |
| 58 | + if ( $useReadline ) { |
| 59 | + $historyFile = "{$_ENV['HOME']}/.mweval_history"; |
| 60 | + readline_read_history( $historyFile ); |
| 61 | + } |
| 62 | + |
| 63 | + while ( ( $line = readconsole( '> ' ) ) !== false ) { |
| 64 | + if ( $useReadline ) { |
| 65 | + readline_add_history( $line ); |
| 66 | + readline_write_history( $historyFile ); |
| 67 | + } |
| 68 | + $val = eval( $line . ";" ); |
| 69 | + if( is_null( $val ) ) { |
| 70 | + echo "\n"; |
| 71 | + } elseif( is_string( $val ) || is_numeric( $val ) ) { |
| 72 | + echo "$val\n"; |
| 73 | + } else { |
| 74 | + var_dump( $val ); |
| 75 | + } |
| 76 | + } |
| 77 | + print "\n"; |
37 | 78 | } |
38 | | - if ( $d > 2 ) { |
39 | | - $wgDebugFunctionEntry = true; |
40 | | - } |
41 | 79 | } |
42 | 80 | |
43 | | -if ( function_exists( 'readline_add_history' ) |
44 | | - && function_exists( 'posix_isatty' ) && posix_isatty( 0 /*STDIN*/ ) ) |
45 | | -{ |
46 | | - $useReadline = true; |
47 | | -} else { |
48 | | - $useReadline = false; |
49 | | -} |
50 | | - |
51 | | -if ( $useReadline ) { |
52 | | - $historyFile = "{$_ENV['HOME']}/.mweval_history"; |
53 | | - readline_read_history( $historyFile ); |
54 | | -} |
55 | | - |
56 | | -while ( ( $line = readconsole( '> ' ) ) !== false ) { |
57 | | - if ( $useReadline ) { |
58 | | - readline_add_history( $line ); |
59 | | - readline_write_history( $historyFile ); |
60 | | - } |
61 | | - $val = eval( $line . ";" ); |
62 | | - if( is_null( $val ) ) { |
63 | | - echo "\n"; |
64 | | - } elseif( is_string( $val ) || is_numeric( $val ) ) { |
65 | | - echo "$val\n"; |
66 | | - } else { |
67 | | - var_dump( $val ); |
68 | | - } |
69 | | -} |
70 | | - |
71 | | -print "\n"; |
72 | | - |
73 | | - |
| 81 | +$maintClass = "EvalPrompt"; |
| 82 | +require_once( DO_MAINTENANCE ); |