From: Peter Frühwirt Date: Sat, 7 Dec 2019 16:26:35 +0000 (+0100) Subject: Fix LabelFormField for objects without labels X-Git-Tag: 5.2.0_RC_1~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=293817582647ae5e196b3ffc56314eeca999cee2;p=GitHub%2FWoltLab%2FWCF.git Fix LabelFormField for objects without labels LabelHandler will return an empty array if no label was attached to an object, which will result in undefined offset error in the LabelFormField --- diff --git a/wcfsetup/install/files/lib/system/form/builder/field/label/LabelFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/label/LabelFormField.class.php index ce3d6476a7..8d83511939 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/label/LabelFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/label/LabelFormField.class.php @@ -105,10 +105,11 @@ class LabelFormField extends AbstractFormField implements IObjectTypeFormNode { static::$loadedLabels[$objectTypeID] = []; } if (!isset(static::$loadedLabels[$objectTypeID][$objectID])) { - static::$loadedLabels[$objectTypeID][$objectID] = LabelHandler::getInstance()->getAssignedLabels( + $assignedLabels = LabelHandler::getInstance()->getAssignedLabels( $objectTypeID, [$objectID] - )[$objectID]; + ); + static::$loadedLabels[$objectTypeID][$objectID] = isset($assignedLabels[$objectID]) ? $assignedLabels[$objectID] : []; } $labelIDs = $this->getLabelGroup()->getLabelIDs();