From 0f45d97c71030d8507086b953789537327dd1fa9 Mon Sep 17 00:00:00 2001 From: Patrick Barabe Date: Wed, 22 May 2024 09:00:49 -0700 Subject: [PATCH] Fix deprecation error in I18n (#71) Utility\I18n's protected _bindTextDomain method was sometimes assigning an array key to an array element that evaluated as false. This was trigging deprecation error 'Automatic conversion of false to array is deprecated'. This modification checks whether the array element is false and explicitly converts it to an array if it is. closes #70 --- lib/Cake/I18n/I18n.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 814c2cfe0..56a92f52b 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -437,7 +437,13 @@ class I18n { } if ($translations !== false) { - $this->_domains[$domain][$this->_lang][$this->category] = $translations; + if ($this->_domains[$domain][$this->_lang] === false) { + $this->_domains[$domain][$this->_lang] = [ + $this->category => $translations + ]; + } else { + $this->_domains[$domain][$this->_lang][$this->category] = $translations; + } $this->_noLocale = false; break 2; } @@ -445,7 +451,13 @@ class I18n { } if (empty($this->_domains[$domain][$this->_lang][$this->category])) { - $this->_domains[$domain][$this->_lang][$this->category] = array(); + if ($this->_domains[$domain][$this->_lang] === false) { + $this->_domains[$domain][$this->_lang] = [ + $this->category => [] + ]; + } else { + $this->_domains[$domain][$this->_lang][$this->category] = []; + } return $domain; }