Skip to content

Commit a8f1f16

Browse files
Merge pull request SimpleMachines#9084 from Sesquipedalian/3.0/uninitialized_cat
Fixes error about accessing SMF\Board::$cat before initialization
2 parents eecc0dc + 6f70ab3 commit a8f1f16

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/Board.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,15 @@ public static function unload(int $id): void
935935
}
936936

937937
// Can we unload the category too?
938-
if ($id > 0 && self::$loaded[$id]->cat?->id > 0 && array_filter(self::$loaded, fn($b) => $b->id !== $id && $b->cat?->id === self::$loaded[$id]->cat->id) === []) {
938+
if (
939+
$id > 0
940+
&& isset(self::$loaded[$id]->cat)
941+
&& self::$loaded[$id]->cat->id > 0
942+
&& [] === array_filter(
943+
self::$loaded,
944+
fn($b) => $b->id !== $id && $b->cat?->id === self::$loaded[$id]->cat->id,
945+
)
946+
) {
939947
Category::unload(self::$loaded[$id]->cat->id);
940948
}
941949

0 commit comments

Comments
 (0)