From bebb26eb2663a21a90dea5086f6b883b8bd6b0f7 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 23 Aug 2019 14:15:33 +0100 Subject: [PATCH] filebackend: Remove private handleWarning in favour of local closure This is a pattern from before PHP 5.3, which we no longer need. Change-Id: I886d1ded25ffe1ee12b6a3f8d48c04aa7dd2ef51 --- includes/libs/filebackend/FSFileBackend.php | 31 ++++++++++----------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/includes/libs/filebackend/FSFileBackend.php b/includes/libs/filebackend/FSFileBackend.php index e6a49c7dd4..c05dc286c8 100644 --- a/includes/libs/filebackend/FSFileBackend.php +++ b/includes/libs/filebackend/FSFileBackend.php @@ -795,8 +795,16 @@ class FSFileBackend extends FileBackendStore { * Listen for E_WARNING errors and track whether any happen */ protected function trapWarnings() { - $this->hadWarningErrors[] = false; // push to stack - set_error_handler( [ $this, 'handleWarning' ], E_WARNING ); + // push to stack + $this->hadWarningErrors[] = false; + set_error_handler( function ( $errno, $errstr ) { + // more detailed error logging + $this->logger->error( $errstr ); + $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true; + + // suppress from PHP handler + return true; + }, E_WARNING ); } /** @@ -805,20 +813,9 @@ class FSFileBackend extends FileBackendStore { * @return bool */ protected function untrapWarnings() { - restore_error_handler(); // restore previous handler - return array_pop( $this->hadWarningErrors ); // pop from stack - } - - /** - * @param int $errno - * @param string $errstr - * @return bool - * @private - */ - public function handleWarning( $errno, $errstr ) { - $this->logger->error( $errstr ); // more detailed error logging - $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true; - - return true; // suppress from PHP handler + // restore previous handler + restore_error_handler(); + // pop from stack + return array_pop( $this->hadWarningErrors ); } } -- 2.20.1