From 08f228f02a15333a1b6f20e08f74017741d0511a Mon Sep 17 00:00:00 2001 From: Kamil Wylegala Date: Tue, 4 Jan 2022 17:08:25 +0100 Subject: [PATCH] Fixed deprecation notice about 'preg_match(): Passing null to parameter #2 () of type string is deprecated' --- lib/Cake/Routing/Route/CakeRoute.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index 85dbb59c9..8149ce39a 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -470,7 +470,8 @@ class CakeRoute { //check patterns for routed params if (!empty($this->options)) { foreach ($this->options as $key => $pattern) { - if (array_key_exists($key, $url) && !preg_match('#^' . $pattern . '$#', $url[$key])) { + //Fixing deprecation notice about null $subject in PHP8.1. + if (array_key_exists($key, $url) && !preg_match('#^' . $pattern . '$#', $url[$key] ?? "")) { return false; } }