Remove jetbrains/phpstorm-stubs from composer dev dependancies
[lhc/web/wiklou.git] / maintenance / eval.php
index 3f10a33..40d29ef 100644 (file)
  * @ingroup Maintenance
  */
 
-$optionsWithArgs = array( 'd' );
+use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\Logger\ConsoleSpi;
+use MediaWiki\MediaWikiServices;
+
+$optionsWithArgs = [ 'd' ];
 
-/** */
 require_once __DIR__ . "/commandLine.inc";
 
 if ( isset( $options['d'] ) ) {
        $d = $options['d'];
        if ( $d > 0 ) {
-               $wgDebugLogFile = '/dev/stdout';
+               LoggerFactory::registerProvider( new ConsoleSpi );
+               // Some services hold Logger instances in object properties
+               MediaWikiServices::resetGlobalInstance();
        }
        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 );
-               }
+               wfGetDB( DB_MASTER )->setFlag( DBO_DEBUG );
+               wfGetDB( DB_REPLICA )->setFlag( DBO_DEBUG );
        }
 }
 
@@ -60,11 +60,6 @@ if ( $__useReadline ) {
        readline_read_history( $__historyFile );
 }
 
-$__phpPath = preg_match( '/Zend Engine|HipHop VM/', wfShellExecWithStderr( 'php --version' ) )
-       ? 'php' //standard system path name
-       : ''; // not accessible somehow
-
-$__multiLine = '';
 $__e = null; // PHP exception
 while ( ( $__line = Maintenance::readconsole() ) !== false ) {
        if ( $__e && !preg_match( '/^(exit|die);?$/', $__line ) ) {
@@ -79,18 +74,8 @@ while ( ( $__line = Maintenance::readconsole() ) !== false ) {
                readline_add_history( $__line );
                readline_write_history( $__historyFile );
        }
-       // Try to only run PHP once a valid chunk is formed (deals with newlines)
-       if ( $__phpPath ) {
-               $res = wfShellExecWithStderr(
-                       "echo " . wfEscapeShellArg( "<?php\n{$__multiLine}{$__line}" ) . " | php -l" );
-               if ( strpos( $res, 'No syntax errors' ) !== 0 && substr( $__multiLine, -2 ) !== "\n\n" ) {
-                       $__multiLine .= "$__line\n";
-                       continue;
-               }
-       }
        try {
-               $__val = eval( $__multiLine . $__line . ";" );
-               $__multiLine = '';
+               $__val = eval( $__line . ";" );
        } catch ( Exception $__e ) {
                echo "Caught exception " . get_class( $__e ) .
                        ": {$__e->getMessage()}\n" . $__e->getTraceAsString() . "\n";