From 7448d45536a13f77abe9eec6655e01fb345f01c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pe=C5=A1ek?= Date: Fri, 2 Feb 2024 15:03:41 +0100 Subject: [PATCH] fix: get rid of (some) PHP deprecation warnings - CakeResponse.php strlen() no longer accepts null as a parameter --- README.md | 4 ++++ lib/Cake/Network/CakeResponse.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 520dfc720b..66be9e22f6 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-02-02 + +- `str_len` deprecation warning fix in CakeResponse (passing null instead of `string`) + ### 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 cd24b2aad7..b37c46f472 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -516,7 +516,7 @@ protected function _setContentLength() { if (ini_get('mbstring.func_overload') & 2 && function_exists('mb_strlen')) { $this->length($offset + mb_strlen($this->_body, '8bit')); } else { - $this->length($this->_headers['Content-Length'] = $offset + strlen($this->_body)); + $this->length($this->_headers['Content-Length'] = $offset + ($this->_body === null ? 0 : strlen($this->_body))); } } }