From 268edfd9e4673dace0d8e9dd9aab357cf3033dc3 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sat, 14 Jan 2012 22:21:30 +0000 Subject: [PATCH] Revert r108777 (making eval subclass maintenance). eval's supposed to be in the global context. See r54839 --- maintenance/eval.php | 99 +++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 57 deletions(-) diff --git a/maintenance/eval.php b/maintenance/eval.php index ac0fe55c9c..3bd164fdaf 100644 --- a/maintenance/eval.php +++ b/maintenance/eval.php @@ -31,69 +31,54 @@ * @ingroup Maintenance */ -require_once( dirname( __FILE__ ) . '/Maintenance.php' ); +$optionsWithArgs = array( 'd' ); -class MwEval extends Maintenance { - public function __construct() { - parent::__construct(); - $this->mDescription = "This script lets a command-line user start up the wiki engine and then poke about by issuing PHP commands directly."; - $this->addOption( 'd', 'Debug level' ); - } - - public function execute() { - if ( $this->hasOption( 'd' ) ) { - $d = $this->getOption( 'd' ); +/** */ +require_once( dirname( __FILE__ ) . "/commandLine.inc" ); - if ( $d > 0 ) { - global $wgDebugLogFile; - $wgDebugLogFile = '/dev/stdout'; - } - if ( $d > 1 ) { - $lb = wfGetLB(); - $serverCount = $lb->getServerCount(); - for ( $i = 0; $i < $serverCount; $i++ ) { - $server = $lb->getServerInfo( $i ); - $server['flags'] |= DBO_DEBUG; - $lb->setServerInfo( $i, $server ); - } - } - if ( $d > 2 ) { - global $wgDebugFunctionEntry; - $wgDebugFunctionEntry = true; - } +if ( isset( $options['d'] ) ) { + $d = $options['d']; + if ( $d > 0 ) { + $wgDebugLogFile = '/dev/stdout'; + } + if ( $d > 1 ) { + $lb = wfGetLB(); + $serverCount = $lb->getServerCount(); + for ( $i = 0; $i < $serverCount; $i++ ) { + $server = $lb->getServerInfo( $i ); + $server['flags'] |= DBO_DEBUG; + $lb->setServerInfo( $i, $server ); } + } + if ( $d > 2 ) { + $wgDebugFunctionEntry = true; + } +} - $useReadline = function_exists( 'readline_add_history' ) - && Maintenance::posix_isatty( 0 /*STDIN*/ ); +$useReadline = function_exists( 'readline_add_history' ) + && Maintenance::posix_isatty( 0 /*STDIN*/ ); - if ( $useReadline ) { - global $IP; - $historyFile = isset( $_ENV['HOME'] ) ? - "{$_ENV['HOME']}/.mweval_history" : "$IP/maintenance/.mweval_history"; - readline_read_history( $historyFile ); - } - - while ( ( $line = Maintenance::readconsole() ) !== false ) { - if ( $useReadline ) { - readline_add_history( $line ); - readline_write_history( $historyFile ); - } - $val = eval( $line . ";" ); - if ( wfIsHipHop() || is_null( $val ) ) { - $this->output( "\n" ); - echo "\n"; - } elseif ( is_string( $val ) || is_numeric( $val ) ) { - $this->output( "$val\n" ); - } else { - $var = ''; - var_export( $val, $var ); - $this->output( "$var" ); - } - } +if ( $useReadline ) { + $historyFile = isset( $_ENV['HOME'] ) ? + "{$_ENV['HOME']}/.mweval_history" : "$IP/maintenance/.mweval_history"; + readline_read_history( $historyFile ); +} - $this->output( "\n" ); +while ( ( $line = Maintenance::readconsole() ) !== false ) { + if ( $useReadline ) { + readline_add_history( $line ); + readline_write_history( $historyFile ); + } + $val = eval( $line . ";" ); + if ( wfIsHipHop() || is_null( $val ) ) { + echo "\n"; + } elseif ( is_string( $val ) || is_numeric( $val ) ) { + echo "$val\n"; + } else { + var_dump( $val ); } } -$maintClass = "MwEval"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +print "\n"; + + -- 2.20.1