From 2ebb0ca271b24a9b13dcc9717496068a09e51417 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Sat, 7 Oct 2017 00:31:06 +0000 Subject: [PATCH] Suppress error in MediaWiki\Shell\Command Command uses a certain error message to detect and ignore EINTR in stream_select, and uses trigger_error to clear the message from get_last_error (clear_last_error is PHP7 only). This works rather poorly with a system config that does not catch or ignore most errors; specifically it breaks database tests on Vagrant with the warnings_as_errors role on. Change-Id: I9c8f922bc0a8f5ee6b8e7501b22223cce4f98ecb --- includes/shell/Command.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/shell/Command.php b/includes/shell/Command.php index fd8f6a0ca7..037ad54d75 100644 --- a/includes/shell/Command.php +++ b/includes/shell/Command.php @@ -315,12 +315,20 @@ class Command { $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; -- 2.20.1