MediaWiki  1.23.2
eval.php
Go to the documentation of this file.
1 <?php
34 
36 require_once __DIR__ . "/commandLine.inc";
37 
38 if ( isset( $options['d'] ) ) {
39  $d = $options['d'];
40  if ( $d > 0 ) {
41  $wgDebugLogFile = '/dev/stdout';
42  }
43  if ( $d > 1 ) {
44  $lb = wfGetLB();
45  $serverCount = $lb->getServerCount();
46  for ( $i = 0; $i < $serverCount; $i++ ) {
47  $server = $lb->getServerInfo( $i );
48  $server['flags'] |= DBO_DEBUG;
49  $lb->setServerInfo( $i, $server );
50  }
51  }
52  if ( $d > 2 ) {
53  $wgDebugFunctionEntry = true;
54  }
55 }
56 
57 $useReadline = function_exists( 'readline_add_history' )
58  && Maintenance::posix_isatty( 0 /*STDIN*/ );
59 
60 if ( $useReadline ) {
61  $historyFile = isset( $_ENV['HOME'] ) ?
62  "{$_ENV['HOME']}/.mweval_history" : "$IP/maintenance/.mweval_history";
63  readline_read_history( $historyFile );
64 }
65 
66 $e = null; // PHP exception
67 while ( ( $line = Maintenance::readconsole() ) !== false ) {
68  if ( $e && !preg_match( '/^(exit|die);?$/', $line ) ) {
69  // Internal state may be corrupted or fatals may occur later due
70  // to some object not being set. Don't drop out of eval in case
71  // lines were being pasted in (which would then get dumped to the shell).
72  // Instead, just absorb the remaning commands. Let "exit" through per DWIM.
73  echo "Exception was thrown before; please restart eval.php\n";
74  continue;
75  }
76  if ( $useReadline ) {
77  readline_add_history( $line );
78  readline_write_history( $historyFile );
79  }
80  try {
81  $val = eval( $line . ";" );
82  } catch ( Exception $e ) {
83  echo "Caught exception " . get_class( $e ) .
84  ": {$e->getMessage()}\n" . $e->getTraceAsString() . "\n";
85  continue;
86  }
87  if ( wfIsHHVM() || is_null( $val ) ) {
88  echo "\n";
89  } elseif ( is_string( $val ) || is_numeric( $val ) ) {
90  echo "$val\n";
91  } else {
92  var_dump( $val );
93  }
94 }
95 
96 print "\n";
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
wfGetLB
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:3660
Maintenance\readconsole
static readconsole( $prompt='> ')
Prompt the console for input.
Definition: Maintenance.php:1134
$lb
if( $wgAPIRequestLog) $lb
Definition: api.php:126
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
$line
$line
Definition: cdb.php:57
Maintenance\posix_isatty
static posix_isatty( $fd)
Wrapper for posix_isatty() We default as considering stdin a tty (for nice readline methods) but trea...
Definition: Maintenance.php:1121
$optionsWithArgs
$optionsWithArgs
Definition: eval.php:33
$useReadline
if(isset( $options['d'])) $useReadline
Definition: eval.php:57
$e
if( $useReadline) $e
Definition: eval.php:66
wfIsHHVM
wfIsHHVM()
Check if we are running under HHVM.
Definition: GlobalFunctions.php:2537
DBO_DEBUG
const DBO_DEBUG
Definition: Defines.php:39