From e772beb72ad818d5fadd724dc6a1e11b12a9c651 Mon Sep 17 00:00:00 2001 From: Maciej Holyszko <14310995+falkenhawk@users.noreply.github.com> Date: Sun, 26 Sep 2021 11:40:39 +0200 Subject: [PATCH 1/2] [zend-loader] refactor broken resolvePharParentPath static method (which never worked properly anyway because of that `if ($value !== '...') return` condition) into an inline foreach loop which discards '..' values from path parts array, in a way that also previous part is discarded when '..' is found. This also fixes `Zend_Loader_ClassMapAutoloader::resolvePharParentPath(): Argument #3 ($parts) must be passed by reference, value given` error on php8. --- .../Zend/Loader/ClassMapAutoloader.php | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/zend-loader/library/Zend/Loader/ClassMapAutoloader.php b/packages/zend-loader/library/Zend/Loader/ClassMapAutoloader.php index a245fbd8a..44e34e900 100644 --- a/packages/zend-loader/library/Zend/Loader/ClassMapAutoloader.php +++ b/packages/zend-loader/library/Zend/Loader/ClassMapAutoloader.php @@ -208,7 +208,17 @@ public static function realPharPath($path) $prependSlash = $parts && $parts[0] === '' ? '/' : ''; $parts = array_values(array_filter($parts, array(__CLASS__, 'concatPharParts'))); - array_walk($parts, array(__CLASS__, 'resolvePharParentPath'), $parts); + // resolve parent paths - discard occurrences of '..' and point to parent directory + $out = array(); + foreach ($parts as $value) { + if ($value === '..') { + array_pop($out); + continue; + } + $out[] = $value; + } + $parts = $out; + if (file_exists($realPath = 'phar://' . $prependSlash . implode('/', $parts))) { return $realPath; } @@ -224,21 +234,4 @@ public static function concatPharParts($part) { return ($part !== '' && $part !== '.'); } - - /** - * Helper callback to resolve a parent path in a Phar archive - * - * @param string $value - * @param int $key - * @param array $parts - * @return void - */ - public static function resolvePharParentPath($value, $key, &$parts) - { - if ($value !== '...') { - return; - } - unset($parts[$key], $parts[$key-1]); - $parts = array_values($parts); - } } From 8495a2f5d2d3490093283946a712e1821693b1be Mon Sep 17 00:00:00 2001 From: Maciej Holyszko <14310995+falkenhawk@users.noreply.github.com> Date: Sun, 26 Sep 2021 12:03:08 +0200 Subject: [PATCH 2/2] disallow test failures on php 8.0 --- .github/workflows/tests.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d5a8795e2..5879e9027 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,10 +23,7 @@ jobs: - "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 + - "8.0" env: MYSQL_USER: "zftest"