From d3c0f5c0cab8ab818e4a4c5b5dc52a441209d028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pe=C5=A1ek?= Date: Fri, 19 Jan 2024 14:43:05 +0100 Subject: [PATCH] fix: get rid of (some) PHP deprecation warnings - CakeResponse.php strotime() and preg_split() warnings --- README.md | 4 ++++ lib/Cake/Network/CakeResponse.php | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 520dfc720..b744ad198 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ It means that composer will look at `master` branch of repository configured und ## Changelog +### 2024-01-19 + +- `strotime()` and `preg_split()` in CakeResponse deprecation warning fixes (passing null) + ### 2024-01-11 - `preg_replace` deprecation warning fixes (passing null instead of `string`) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 8ede7e513..adf0ab72b 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1164,11 +1164,7 @@ public function checkNotModified(CakeRequest $request) { $ifNoneMatchHeader = $request->header('If-None-Match'); $etags = array(); if (is_string($ifNoneMatchHeader)) { - $etags = preg_split( - pattern: '/\s*,\s*/', - subject: $ifNoneMatchHeader, - flags: PREG_SPLIT_NO_EMPTY - ); + $etags = preg_split('/\s*,\s*/', $ifNoneMatchHeader, 0, PREG_SPLIT_NO_EMPTY); } $modifiedSince = $request->header('If-Modified-Since'); $checks = array(); @@ -1176,7 +1172,11 @@ public function checkNotModified(CakeRequest $request) { $checks[] = in_array('*', $etags) || in_array($responseTag, $etags); } if ($modifiedSince) { - $checks[] = strtotime($this->modified()) === strtotime($modifiedSince); + if ($this->modified() === null) { + $checks[] = strtotime($modifiedSince) === false; + } else { + $checks[] = strtotime($this->modified()) === strtotime($modifiedSince); + } } if (empty($checks)) { return false;