From 9140745ef18668b4a03ef3df208af85571bc95ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pe=C5=A1ek?= Date: Sat, 3 Feb 2024 10:26:26 +0100 Subject: [PATCH] fix: get rid of (some) PHP deprecation warnings (#66) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CakeResponse.php strlen() no longer accepts null as a parameter Co-authored-by: Jan Pešek --- 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 b744ad198..23655ed0d 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-19 - `strotime()` and `preg_split()` in CakeResponse deprecation warning fixes (passing null) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index adf0ab72b..6ad28da51 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))); } } }