修复当 $myid 为字符串类型时出现的无限递归的问题

由于 PHP 中 0 == 字符串永远等于 true 的特性,该处容易出现判断错误。
- 为什么不用 ===
因为很多情况可能会搞不清当前数据是 0 还是 '0' ,使用类型转换更加兼容。
pull/377/head
T2cc 2022-01-18 05:27:34 +00:00 committed by Gitee
parent edec9f7fe1
commit 077bba602d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 2 additions and 2 deletions

View File

@ -112,10 +112,10 @@ class Tree
if (!isset($value['id'])) {
continue;
}
if ($value[$this->pidname] == $myid) {
if ((string)$value[$this->pidname] == (string)$myid) {
$newarr[] = $value;
$newarr = array_merge($newarr, $this->getChildren($value['id']));
} elseif ($withself && $value['id'] == $myid) {
} elseif ($withself && (string)$value['id'] == (string)$myid) {
$newarr[] = $value;
}
}