mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix null path in Hash::get() causing exceptions.
This was a regression introduced in 2.6.x Refs #6297
This commit is contained in:
parent
4a7344ae80
commit
a6aefdd4d3
2 changed files with 4 additions and 2 deletions
|
@ -247,6 +247,9 @@ class HashTest extends CakeTestCase {
|
|||
public function testGetNullPath() {
|
||||
$result = Hash::get(array('one' => 'two'), null, '-');
|
||||
$this->assertEquals('-', $result);
|
||||
|
||||
$result = Hash::get(array('one' => 'two'), '', '-');
|
||||
$this->assertEquals('-', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,7 @@ class Hash {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::get
|
||||
*/
|
||||
public static function get(array $data, $path, $default = null) {
|
||||
if (empty($data)) {
|
||||
if (empty($data) || $path === '' || $path === null) {
|
||||
return $default;
|
||||
}
|
||||
if (is_string($path) || is_numeric($path)) {
|
||||
|
@ -55,7 +55,6 @@ class Hash {
|
|||
$path
|
||||
));
|
||||
}
|
||||
|
||||
$parts = $path;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue