r108942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108941‎ | r108942 | r108943 >
Date:22:21, 14 January 2012
Author:demon
Status:ok
Tags:
Comment:
Revert r108777 (making eval subclass maintenance). eval's supposed to be in the global context. See r54839
Modified paths:
  • /trunk/phase3/maintenance/eval.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/eval.php
@@ -31,69 +31,54 @@
3232 * @ingroup Maintenance
3333 */
3434
35 -require_once( dirname( __FILE__ ) . '/Maintenance.php' );
 35+$optionsWithArgs = array( 'd' );
3636
37 -class MwEval extends Maintenance {
38 - public function __construct() {
39 - parent::__construct();
40 - $this->mDescription = "This script lets a command-line user start up the wiki engine and then poke about by issuing PHP commands directly.";
41 - $this->addOption( 'd', 'Debug level' );
42 - }
 37+/** */
 38+require_once( dirname( __FILE__ ) . "/commandLine.inc" );
4339
44 - public function execute() {
45 - if ( $this->hasOption( 'd' ) ) {
46 - $d = $this->getOption( 'd' );
47 -
48 - if ( $d > 0 ) {
49 - global $wgDebugLogFile;
50 - $wgDebugLogFile = '/dev/stdout';
51 - }
52 - if ( $d > 1 ) {
53 - $lb = wfGetLB();
54 - $serverCount = $lb->getServerCount();
55 - for ( $i = 0; $i < $serverCount; $i++ ) {
56 - $server = $lb->getServerInfo( $i );
57 - $server['flags'] |= DBO_DEBUG;
58 - $lb->setServerInfo( $i, $server );
59 - }
60 - }
61 - if ( $d > 2 ) {
62 - global $wgDebugFunctionEntry;
63 - $wgDebugFunctionEntry = true;
64 - }
 40+if ( isset( $options['d'] ) ) {
 41+ $d = $options['d'];
 42+ if ( $d > 0 ) {
 43+ $wgDebugLogFile = '/dev/stdout';
 44+ }
 45+ if ( $d > 1 ) {
 46+ $lb = wfGetLB();
 47+ $serverCount = $lb->getServerCount();
 48+ for ( $i = 0; $i < $serverCount; $i++ ) {
 49+ $server = $lb->getServerInfo( $i );
 50+ $server['flags'] |= DBO_DEBUG;
 51+ $lb->setServerInfo( $i, $server );
6552 }
 53+ }
 54+ if ( $d > 2 ) {
 55+ $wgDebugFunctionEntry = true;
 56+ }
 57+}
6658
67 - $useReadline = function_exists( 'readline_add_history' )
68 - && Maintenance::posix_isatty( 0 /*STDIN*/ );
 59+$useReadline = function_exists( 'readline_add_history' )
 60+ && Maintenance::posix_isatty( 0 /*STDIN*/ );
6961
70 - if ( $useReadline ) {
71 - global $IP;
72 - $historyFile = isset( $_ENV['HOME'] ) ?
73 - "{$_ENV['HOME']}/.mweval_history" : "$IP/maintenance/.mweval_history";
74 - readline_read_history( $historyFile );
75 - }
 62+if ( $useReadline ) {
 63+ $historyFile = isset( $_ENV['HOME'] ) ?
 64+ "{$_ENV['HOME']}/.mweval_history" : "$IP/maintenance/.mweval_history";
 65+ readline_read_history( $historyFile );
 66+}
7667
77 - while ( ( $line = Maintenance::readconsole() ) !== false ) {
78 - if ( $useReadline ) {
79 - readline_add_history( $line );
80 - readline_write_history( $historyFile );
81 - }
82 - $val = eval( $line . ";" );
83 - if ( wfIsHipHop() || is_null( $val ) ) {
84 - $this->output( "\n" );
85 - echo "\n";
86 - } elseif ( is_string( $val ) || is_numeric( $val ) ) {
87 - $this->output( "$val\n" );
88 - } else {
89 - $var = '';
90 - var_export( $val, $var );
91 - $this->output( "$var" );
92 - }
93 - }
94 -
95 - $this->output( "\n" );
 68+while ( ( $line = Maintenance::readconsole() ) !== false ) {
 69+ if ( $useReadline ) {
 70+ readline_add_history( $line );
 71+ readline_write_history( $historyFile );
9672 }
 73+ $val = eval( $line . ";" );
 74+ if ( wfIsHipHop() || is_null( $val ) ) {
 75+ echo "\n";
 76+ } elseif ( is_string( $val ) || is_numeric( $val ) ) {
 77+ echo "$val\n";
 78+ } else {
 79+ var_dump( $val );
 80+ }
9781 }
9882
99 -$maintClass = "MwEval";
100 -require_once( RUN_MAINTENANCE_IF_MAIN );
 83+print "\n";
 84+
 85+

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54839Revert eval.php changes from r54653, r54312, r54225 (maintenance-work branch ...tstarling03:44, 12 August 2009
r108777Maintenance class-ify eval.phpreedy23:10, 12 January 2012

Status & tagging log