Skip to content

Commit b8e9600

Browse files
committed
Fix the array index
1 parent 293ac36 commit b8e9600

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

wcfsetup/install/files/lib/data/page/PageNodeTree.class.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ public function __construct($parentID = null, $startDepth = 0)
6161
foreach ($pageList as $page) {
6262
$this->pages[$page->pageID] = $page;
6363

64-
if (!isset($this->pageStructure[$page->parentPageID])) {
65-
$this->pageStructure[$page->parentPageID] = [];
66-
}
67-
$this->pageStructure[$page->parentPageID][] = $page->pageID;
64+
$parentPageID = $page->parentPageID ?? 0;
65+
$this->pageStructure[$parentPageID] ??= [];
66+
$this->pageStructure[$parentPageID][] = $page->pageID;
6867
}
6968

7069
// generate node tree
@@ -75,14 +74,13 @@ public function __construct($parentID = null, $startDepth = 0)
7574
/**
7675
* Generates the node tree recursively.
7776
*
78-
* @param int $parentID
79-
* @param PageNode $parentNode
80-
* @return PageNode[]
77+
* @return list<PageNode>
8178
*/
82-
protected function generateNodeTree($parentID, ?PageNode $parentNode = null)
79+
protected function generateNodeTree(?int $parentID, ?PageNode $parentNode = null)
8380
{
8481
$nodes = [];
8582

83+
$parentID ??= 0;
8684
$pageIDs = ($this->pageStructure[$parentID] ?? []);
8785
foreach ($pageIDs as $pageID) {
8886
$page = $this->pages[$pageID];

0 commit comments

Comments
 (0)