Remove some stray executable bits
[lhc/web/wiklou.git] / maintenance / eval.php
1 <?php
2 /**
3 * PHP lacks an interactive mode, but this can be very helpful when debugging.
4 * This script lets a command-line user start up the wiki engine and then poke
5 * about by issuing PHP commands directly.
6 *
7 * Unlike eg Python, you need to use a 'return' statement explicitly for the
8 * interactive shell to print out the value of the expression. Multiple lines
9 * are evaluated separately, so blocks need to be input without a line break.
10 * Fatal errors such as use of undeclared functions can kill the shell.
11 *
12 * To get decent line editing behavior, you should compile PHP with support
13 * for GNU readline (pass --with-readline to configure).
14 *
15 * @package MediaWiki
16 * @subpackage Maintenance
17 */
18
19 $wgForceLoadBalancing = (getenv('MW_BALANCE') ? true : false);
20 $wgUseNormalUser = (getenv('MW_WIKIUSER') ? true : false);
21 if (getenv('MW_PROFILING')) {
22 define('MW_CMDLINE_CALLBACK', 'wfSetProfiling');
23 }
24 function wfSetProfiling() { $GLOBALS['wgProfiling'] = true; }
25
26 $optionsWithArgs = array( 'd' );
27
28 /** */
29 require_once( "commandLine.inc" );
30
31 if ( isset( $options['d'] ) ) {
32 $d = $options['d'];
33 if ( $d > 0 ) {
34 $wgDebugLogFile = '/dev/stdout';
35 }
36 if ( $d > 1 ) {
37 foreach ( $wgLoadBalancer->mServers as $i => $server ) {
38 $wgLoadBalancer->mServers[$i]['flags'] |= DBO_DEBUG;
39 }
40 }
41 if ( $d > 2 ) {
42 $wgDebugFunctionEntry = true;
43 }
44 }
45
46
47 while ( ( $line = readconsole( '> ' ) ) !== false ) {
48 $val = eval( $line . ";" );
49 if( is_null( $val ) ) {
50 echo "\n";
51 } elseif( is_string( $val ) || is_numeric( $val ) ) {
52 echo "$val\n";
53 } else {
54 var_dump( $val );
55 }
56 if ( function_exists( "readline_add_history" ) ) {
57 readline_add_history( $line );
58 }
59 }
60
61 print "\n";
62
63 ?>