Merge "Suppress error in MediaWiki\Shell\Command"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 10 Oct 2017 18:52:52 +0000 (18:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 10 Oct 2017 18:52:53 +0000 (18:52 +0000)
1  2 
includes/shell/Command.php

@@@ -199,6 -199,8 +199,6 @@@ class Command 
         * @throws ShellDisabledError
         */
        public function execute() {
 -              global $IP;
 -
                $this->everExecuted = true;
  
                $profileMethod = $this->method ?: wfGetCaller();
                        $filesize = intval( $this->limits['filesize'] );
  
                        if ( $time > 0 || $mem > 0 || $filesize > 0 || $wallTime > 0 ) {
 -                              $cmd = '/bin/bash ' . escapeshellarg( "$IP/includes/limit.sh" ) . ' ' .
 +                              $cmd = '/bin/bash ' . escapeshellarg( __DIR__ . '/limit.sh' ) . ' ' .
                                           escapeshellarg( $cmd ) . ' ' .
                                           escapeshellarg(
                                                   "MW_INCLUDE_STDERR=" . ( $this->useStderr ? '1' : '' ) . ';' .
  
                        $readyPipes = $pipes;
  
-                       // Clear last error
+                       // clear get_last_error without actually raising an error
+                       // from http://php.net/manual/en/function.error-get-last.php#113518
+                       // TODO replace with clear_last_error when requirements are bumped to PHP7
+                       set_error_handler( function () {
+                       }, 0 );
                        // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged
                        @trigger_error( '' );
+                       // @codingStandardsIgnoreEnd
+                       restore_error_handler();
+                       // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged
                        $numReadyPipes = @stream_select( $readyPipes, $emptyArray, $emptyArray, $timeout );
+                       // @codingStandardsIgnoreEnd
                        if ( $numReadyPipes === false ) {
-                               // @codingStandardsIgnoreEnd
                                $error = error_get_last();
                                if ( strncmp( $error['message'], $eintrMessage, strlen( $eintrMessage ) ) == 0 ) {
                                        continue;