Preload box content even for system boxes
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 18 Feb 2021 10:30:33 +0000 (11:30 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 18 Feb 2021 10:30:33 +0000 (11:30 +0100)
Box::getBoxContentTitle() unconditionally loads the box contents for all box
types, because even system boxes might fall back to the box title that is
configured within the ACP.

This might result on O(n) queries when a page has several system boxes.

Fix this issue by preloading the box contents for all boxes.

wcfsetup/install/files/lib/data/box/BoxList.class.php

index 25629605591f8e97a51a08ff1f5da60b97c3c0e1..c9408aa5c58d0025294befd053b1816d07ebd1e1 100644 (file)
@@ -42,14 +42,7 @@ class BoxList extends DatabaseObjectList
 
         // get box content
         if ($this->contentLoading) {
-            $boxIDs = [];
-            foreach ($this->getObjects() as $box) {
-                if ($box->boxType != 'system' && $box->boxType != 'menu') {
-                    $boxIDs[] = $box->boxID;
-                }
-            }
-
-            if (!empty($boxIDs)) {
+            if (!empty($this->objectIDs)) {
                 $contentList = new BoxContentList();
                 $contentList->enableImageLoading();
                 $contentList->enableEmbeddedObjectLoading();