Skip to content

Commit 12e1d2e

Browse files
committed
Merge branch '4.0' into 'main'
2 parents a6c67d1 + 9dcbad0 commit 12e1d2e

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ This is a log of major user-visible changes in each phpMyFAQ release.
2323
- migrated from Webpack to Vite v6 (Thorsten)
2424
- migrated from Jest to Vitest v3 (Thorsten)
2525

26+
### phpMyFAQ v4.0.8 - unreleased
27+
28+
- updated third party dependencies (Thorsten)
29+
- fixed bugs (Thorsten)
30+
2631
### phpMyFAQ v4.0.7 - 2025-03-24
2732

2833
- updated third party dependencies (Thorsten)

composer.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpmyfaq/src/phpMyFAQ/Category/Order.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,16 @@ public function setCategoryTree(
124124
public function getCategoryTree(array $categories, int $parentId = 0): array
125125
{
126126
$result = [];
127+
$stack = [[$parentId, &$result]];
127128

128-
foreach ($categories as $category) {
129-
if ((int) $category['parent_id'] === $parentId) {
130-
$children = $this->getCategoryTree($categories, $category['category_id']);
131-
$result[$category['category_id']] = $children;
129+
while (!empty($stack)) {
130+
list($currentParentId, &$currentResult) = array_pop($stack);
131+
132+
foreach ($categories as $category) {
133+
if ((int) $category['parent_id'] === $currentParentId) {
134+
$currentResult[$category['category_id']] = [];
135+
$stack[] = [$category['category_id'], &$currentResult[$category['category_id']]];
136+
}
132137
}
133138
}
134139

0 commit comments

Comments
 (0)