From d4df7869520679611bc6f640c82249b4f92d10eb Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Mon, 27 Jan 2025 17:37:35 -0500 Subject: [PATCH] Patched UnauthorizedStrategy.php to set the listener priority to -1 such that it runs after the MVC exception handler. Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- composer.lock | 54 ++++++++++++---------- src/View/Strategy/UnauthorizedStrategy.php | 10 ++++ 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/composer.lock b/composer.lock index 583f791..303dd49 100644 --- a/composer.lock +++ b/composer.lock @@ -1301,16 +1301,16 @@ }, { "name": "lm-commons/lmc-rbac", - "version": "2.1.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/LM-Commons/LmcRbac.git", - "reference": "226cd1e9fefb6d9448c0c223820568a680ba8a28" + "reference": "2110f500b6316e24fcf916dedd8bd64b74aeff44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/LM-Commons/LmcRbac/zipball/226cd1e9fefb6d9448c0c223820568a680ba8a28", - "reference": "226cd1e9fefb6d9448c0c223820568a680ba8a28", + "url": "https://api.github.com/repos/LM-Commons/LmcRbac/zipball/2110f500b6316e24fcf916dedd8bd64b74aeff44", + "reference": "2110f500b6316e24fcf916dedd8bd64b74aeff44", "shasum": "" }, "require": { @@ -1387,9 +1387,9 @@ ], "support": { "issues": "https://github.com/LM-Commons/LmcRbac/issues", - "source": "https://github.com/LM-Commons/LmcRbac/tree/2.1.0" + "source": "https://github.com/LM-Commons/LmcRbac/tree/2.1.1" }, - "time": "2025-01-02T17:33:01+00:00" + "time": "2025-01-04T16:25:38+00:00" }, { "name": "nikic/php-parser", @@ -3536,16 +3536,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.40", + "version": "10.5.41", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c" + "reference": "e76586fa3d49714f230221734b44892e384109d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e6ddda95af52f69c1e0c7b4f977cccb58048798c", - "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e76586fa3d49714f230221734b44892e384109d7", + "reference": "e76586fa3d49714f230221734b44892e384109d7", "shasum": "" }, "require": { @@ -3617,7 +3617,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.40" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.41" }, "funding": [ { @@ -3633,28 +3633,28 @@ "type": "tidelift" } ], - "time": "2024-12-21T05:49:06+00:00" + "time": "2025-01-13T09:33:05+00:00" }, { "name": "psalm/plugin-phpunit", - "version": "0.19.0", + "version": "0.19.1", "source": { "type": "git", "url": "https://github.com/psalm/psalm-plugin-phpunit.git", - "reference": "e344eaaa27871e79c6cb97b9efe52a735f9d1966" + "reference": "bc31ef11ce007a181a09dde201f73ac8d0b3b107" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/psalm/psalm-plugin-phpunit/zipball/e344eaaa27871e79c6cb97b9efe52a735f9d1966", - "reference": "e344eaaa27871e79c6cb97b9efe52a735f9d1966", + "url": "https://api.github.com/repos/psalm/psalm-plugin-phpunit/zipball/bc31ef11ce007a181a09dde201f73ac8d0b3b107", + "reference": "bc31ef11ce007a181a09dde201f73ac8d0b3b107", "shasum": "" }, "require": { "composer/package-versions-deprecated": "^1.10", "composer/semver": "^1.4 || ^2.0 || ^3.0", "ext-simplexml": "*", - "php": "^7.4 || ^8.0", - "vimeo/psalm": "dev-master || ^5@beta || ^5.0" + "php": ">=7.4", + "vimeo/psalm": "dev-master || ^5@beta || ^5.0 || ^6.0" }, "conflict": { "phpunit/phpunit": "<7.5" @@ -3691,9 +3691,9 @@ "description": "Psalm plugin for PHPUnit", "support": { "issues": "https://github.com/psalm/psalm-plugin-phpunit/issues", - "source": "https://github.com/psalm/psalm-plugin-phpunit/tree/0.19.0" + "source": "https://github.com/psalm/psalm-plugin-phpunit/tree/0.19.1" }, - "time": "2024-03-15T10:43:15+00:00" + "time": "2025-01-26T09:41:04+00:00" }, { "name": "psr/log", @@ -4796,16 +4796,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.2", + "version": "3.11.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", "shasum": "" }, "require": { @@ -4870,9 +4870,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-12-11T16:04:26+00:00" + "time": "2025-01-23T17:04:15+00:00" }, { "name": "symfony/console", diff --git a/src/View/Strategy/UnauthorizedStrategy.php b/src/View/Strategy/UnauthorizedStrategy.php index c282dab..f6e5a77 100644 --- a/src/View/Strategy/UnauthorizedStrategy.php +++ b/src/View/Strategy/UnauthorizedStrategy.php @@ -21,6 +21,7 @@ namespace Lmc\Rbac\Mvc\View\Strategy; +use Laminas\EventManager\EventManagerInterface; use Laminas\Http\Response as HttpResponse; use Laminas\Mvc\MvcEvent; use Laminas\View\Model\ViewModel; @@ -43,6 +44,15 @@ public function __construct(UnauthorizedStrategyOptions $options) $this->options = $options; } + /** + * @inheritDoc + */ + public function attach(EventManagerInterface $events, $priority = 1): void + { + // Temporary fix to priority to make sure listeners runs after MVC's exception handler + $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, [$this, 'onError'], -1); + } + /** * @private */