|
| 1 | +From a9f3ce4601b5e9061351d2cd95c6ee3d03b278d9 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Mag=C3=AD=20Carbonell?= |
| 3 | + <92313746+mcarbonell-paymefy@users.noreply.github.com> |
| 4 | +Date: Thu, 15 Jan 2026 19:42:40 +0100 |
| 5 | +Subject: [PATCH] Refactor RequestTokenVerifier to address League/Uri |
| 6 | + deprecations |
| 7 | + |
| 8 | +This commit updates RequestTokenVerifier.php to ensure compatibility with newer versions of the league/uri library while maintaining backward compatibility. |
| 9 | + |
| 10 | +Following the pattern established in previous core updates (commit 4efe88d), the following changes were made: |
| 11 | +- Replaced deprecated static factory calls with the new new() method where available. |
| 12 | +- Added method_exists checks for both HttpUri and Path classes to prevent breaking changes in environments using older versions of the library. |
| 13 | +- Aligned imports and class aliases with existing core standards (using HttpUri as an alias for League\Uri\Http). |
| 14 | + |
| 15 | +These changes eliminate deprecation notices in modern PHP environments and unify the URI handling logic across the project. |
| 16 | +--- |
| 17 | + Security/Util/RequestTokenVerifier.php | 19 ++++++++++++++----- |
| 18 | + 1 file changed, 14 insertions(+), 5 deletions(-) |
| 19 | + |
| 20 | +diff --git a/Security/Util/RequestTokenVerifier.php b/Security/Util/RequestTokenVerifier.php |
| 21 | +index 03f64204..dde5898a 100644 |
| 22 | +--- a/Security/Util/RequestTokenVerifier.php |
| 23 | ++++ b/Security/Util/RequestTokenVerifier.php |
| 24 | +@@ -3,7 +3,7 @@ |
| 25 | + namespace Payum\Core\Security\Util; |
| 26 | + |
| 27 | + use League\Uri\Components\Path; |
| 28 | +-use League\Uri\Http; |
| 29 | ++use League\Uri\Http as HttpUri; |
| 30 | + |
| 31 | + class RequestTokenVerifier |
| 32 | + { |
| 33 | +@@ -14,11 +14,20 @@ class RequestTokenVerifier |
| 34 | + */ |
| 35 | + public static function isValid($requestUri, $tokenUri) |
| 36 | + { |
| 37 | +- $uri = Http::createFromString($requestUri); |
| 38 | +- $altUri = Http::createFromString($tokenUri); |
| 39 | ++ $uri = method_exists(HttpUri::class, 'new') ? HttpUri::new($requestUri) : HttpUri::createFromString( |
| 40 | ++ $requestUri |
| 41 | ++ ); |
| 42 | ++ $altUri = method_exists(HttpUri::class, 'new') ? HttpUri::new($tokenUri) : HttpUri::createFromString( |
| 43 | ++ $tokenUri |
| 44 | ++ ); |
| 45 | ++ |
| 46 | + |
| 47 | +- $uriPath = Path::createFromUri($uri); |
| 48 | +- $altUriPath = Path::createFromUri($altUri); |
| 49 | ++ $uriPath = method_exists(Path::class, 'new') ? Path::new($uri) : Path::createFromUri( |
| 50 | ++ $uri |
| 51 | ++ ); |
| 52 | ++ $altUriPath = method_exists(Path::class, 'new') ? Path::new($altUri) : Path::createFromUri( |
| 53 | ++ $altUri |
| 54 | ++ ); |
| 55 | + |
| 56 | + return rawurldecode((string) $uriPath) === rawurldecode((string) $altUriPath); |
| 57 | + } |
0 commit comments