Skip to content

Commit

Permalink
Fix deprecation error in I18n (#71)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pbarabe authored May 22, 2024
1 parent c124297 commit 0f45d97
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Cake/I18n/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,27 @@ protected function _bindTextDomain($domain) {
}

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

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

Expand Down

0 comments on commit 0f45d97

Please sign in to comment.