Fixed deprecation notice about 'preg_match(): Passing null to parameter #2 () of type string is deprecated'

This commit is contained in:
Kamil Wylegala 2022-01-04 17:08:25 +01:00
parent ef0e0a7175
commit 08f228f02a

View file

@ -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;
}
}