From 00830e849b5b47a30332d1b3259f3b030db9996f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 15 Mar 2021 19:49:31 +0200 Subject: [PATCH 1/4] Short-circuit for php 8.0 testing only --- .github/workflows/tests.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4b512efbf..f8ebb578e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,20 +13,9 @@ jobs: matrix: experimental: - false - php: - - "5.3" - - "5.4" - - "5.5" - - "5.6" - - "7.0" - - "7.1" - - "7.2" - - "7.3" - - "7.4" # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations include: - php: "8.0" - experimental: true runs-on: ubuntu-20.04 env: From ebdc301908dcde245c83a03785ddac82bee8654a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 15 Mar 2021 20:20:56 +0200 Subject: [PATCH 2/4] Catch ValueError from fopen() PHP Fatal error: Uncaught TypeError: fopen(): Argument #1 ($filename) must be of type string, XMLParser given --- packages/zend-log/library/Zend/Log/Writer/Stream.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/zend-log/library/Zend/Log/Writer/Stream.php b/packages/zend-log/library/Zend/Log/Writer/Stream.php index 895970567..3402aba54 100644 --- a/packages/zend-log/library/Zend/Log/Writer/Stream.php +++ b/packages/zend-log/library/Zend/Log/Writer/Stream.php @@ -75,7 +75,14 @@ public function __construct($streamOrUrl, $mode = null) $streamOrUrl = $streamOrUrl['stream']; } - if (! $this->_stream = @fopen($streamOrUrl, $mode, false)) { + try { + $this->_stream = @fopen($streamOrUrl, $mode, false); + } catch (TypeError $e) { + // require_once 'Zend/Log/Exception.php'; + throw new Zend_Log_Exception($e->getMessage(), $e->getCode()); + } + + if (!$this->_stream) { // require_once 'Zend/Log/Exception.php'; $msg = "\"$streamOrUrl\" cannot be opened with mode \"$mode\""; throw new Zend_Log_Exception($msg); From b84f97f75fe1901dc04171936203bd514193e904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 15 Mar 2021 20:25:29 +0200 Subject: [PATCH 3/4] Catch also ValueError FPHP Fatal error: Uncaught ValueError: Path cannot be empty --- packages/zend-log/library/Zend/Log/Writer/Stream.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/zend-log/library/Zend/Log/Writer/Stream.php b/packages/zend-log/library/Zend/Log/Writer/Stream.php index 3402aba54..b5d6e4c46 100644 --- a/packages/zend-log/library/Zend/Log/Writer/Stream.php +++ b/packages/zend-log/library/Zend/Log/Writer/Stream.php @@ -77,6 +77,9 @@ public function __construct($streamOrUrl, $mode = null) try { $this->_stream = @fopen($streamOrUrl, $mode, false); + } catch (ValueError $e) { + // require_once 'Zend/Log/Exception.php'; + throw new Zend_Log_Exception($e->getMessage(), $e->getCode()); } catch (TypeError $e) { // require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception($e->getMessage(), $e->getCode()); From 4d9eaa4df5519cc068e4f0ce11fc0e803c5970cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 15 Mar 2021 20:27:16 +0200 Subject: [PATCH 4/4] Catch TypeError in Zend_Log_Writer_Stream::_write Configuration read from /Users/glen/scm/php/zf1/zf1s/phpunit.xml.dist --- packages/zend-log/library/Zend/Log/Writer/Stream.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/zend-log/library/Zend/Log/Writer/Stream.php b/packages/zend-log/library/Zend/Log/Writer/Stream.php index b5d6e4c46..794aa0170 100644 --- a/packages/zend-log/library/Zend/Log/Writer/Stream.php +++ b/packages/zend-log/library/Zend/Log/Writer/Stream.php @@ -140,7 +140,14 @@ protected function _write($event) { $line = $this->_formatter->format($event); - if (false === @fwrite($this->_stream, $line)) { + try { + $result = @fwrite($this->_stream, $line); + } catch (TypeError $e) { + // require_once 'Zend/Log/Exception.php'; + throw new Zend_Log_Exception($e->getMessage(), $e->getCode()); + } + + if ($result === false) { // require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception("Unable to write to stream"); }