From f0ae292da7ef0673b30c68b4a6f3789b2eea8464 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 17 Nov 2014 18:45:49 -0800 Subject: [PATCH] Make eval.php try to handle newlines in code Change-Id: I9f4664bde6bea6f0e1dca0f4623553b9e849c83b --- maintenance/eval.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/maintenance/eval.php b/maintenance/eval.php index e20c477af0..3f10a33b51 100644 --- a/maintenance/eval.php +++ b/maintenance/eval.php @@ -60,6 +60,11 @@ 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 ) ) { @@ -74,8 +79,18 @@ 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( "getMessage()}\n" . $__e->getTraceAsString() . "\n"; -- 2.20.1