MediaWiki
REL1_24
|
00001 <?php 00033 $optionsWithArgs = array( 'd' ); 00034 00036 require_once __DIR__ . "/commandLine.inc"; 00037 00038 if ( isset( $options['d'] ) ) { 00039 $d = $options['d']; 00040 if ( $d > 0 ) { 00041 $wgDebugLogFile = '/dev/stdout'; 00042 } 00043 if ( $d > 1 ) { 00044 $lb = wfGetLB(); 00045 $serverCount = $lb->getServerCount(); 00046 for ( $i = 0; $i < $serverCount; $i++ ) { 00047 $server = $lb->getServerInfo( $i ); 00048 $server['flags'] |= DBO_DEBUG; 00049 $lb->setServerInfo( $i, $server ); 00050 } 00051 } 00052 if ( $d > 2 ) { 00053 $wgDebugFunctionEntry = true; 00054 } 00055 } 00056 00057 $useReadline = function_exists( 'readline_add_history' ) 00058 && Maintenance::posix_isatty( 0 /*STDIN*/ ); 00059 00060 if ( $useReadline ) { 00061 $historyFile = isset( $_ENV['HOME'] ) ? 00062 "{$_ENV['HOME']}/.mweval_history" : "$IP/maintenance/.mweval_history"; 00063 readline_read_history( $historyFile ); 00064 } 00065 00066 $e = null; // PHP exception 00067 while ( ( $line = Maintenance::readconsole() ) !== false ) { 00068 if ( $e && !preg_match( '/^(exit|die);?$/', $line ) ) { 00069 // Internal state may be corrupted or fatals may occur later due 00070 // to some object not being set. Don't drop out of eval in case 00071 // lines were being pasted in (which would then get dumped to the shell). 00072 // Instead, just absorb the remaning commands. Let "exit" through per DWIM. 00073 echo "Exception was thrown before; please restart eval.php\n"; 00074 continue; 00075 } 00076 if ( $useReadline ) { 00077 readline_add_history( $line ); 00078 readline_write_history( $historyFile ); 00079 } 00080 try { 00081 $val = eval( $line . ";" ); 00082 } catch ( Exception $e ) { 00083 echo "Caught exception " . get_class( $e ) . 00084 ": {$e->getMessage()}\n" . $e->getTraceAsString() . "\n"; 00085 continue; 00086 } 00087 if ( wfIsHHVM() || is_null( $val ) ) { 00088 echo "\n"; 00089 } elseif ( is_string( $val ) || is_numeric( $val ) ) { 00090 echo "$val\n"; 00091 } else { 00092 var_dump( $val ); 00093 } 00094 } 00095 00096 print "\n";