From 4e025a44bddf81e4d8abbd907cf19e156e6554a0 Mon Sep 17 00:00:00 2001 From: Stanislas Kita Date: Fri, 24 Apr 2026 09:57:22 +0200 Subject: [PATCH] Fix(Core): Optimize container loading when there are a large number of entities --- CHANGELOG.md | 1 + inc/container.class.php | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dcb8566..8ab8beb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Fix text area fields size and alignment +- Optimize container loading when there are a large number of entities ## [1.24.0] - 2026-04-16 diff --git a/inc/container.class.php b/inc/container.class.php index a966e4df..abcf900b 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -1756,9 +1756,6 @@ public static function findContainer($itemtype, $type = 'tab', $subtype = '') ['type' => $type], ]; - $entity = $_SESSION['glpiactiveentities'] ?? 0; - $condition += getEntitiesRestrictCriteria('', '', $entity, true, true); - if ($subtype != '') { if ($subtype == $itemtype . '$main') { $condition[] = ['type' => 'dom']; @@ -1777,7 +1774,7 @@ public static function findContainer($itemtype, $type = 'tab', $subtype = '') foreach ($itemtypes as $data) { $dataitemtypes = PluginFieldsToolbox::decodeJSONItemtypes($data['itemtypes']); - if (in_array($itemtype, $dataitemtypes)) { + if (in_array($itemtype, $dataitemtypes) && Session::haveAccessToEntity($data['entities_id'], $data['is_recursive'])) { $id = $data['id']; } } @@ -1797,9 +1794,6 @@ public static function findAllContainers($itemtype) { $condition = ['is_active' => 1]; - $entity = $_SESSION['glpiactiveentities'] ?? 0; - $condition += getEntitiesRestrictCriteria('', '', $entity, true, true); - $container = new PluginFieldsContainer(); $itemtypes = $container->find($condition); @@ -1810,7 +1804,7 @@ public static function findAllContainers($itemtype) $ids = []; foreach ($itemtypes as $data) { $dataitemtypes = PluginFieldsToolbox::decodeJSONItemtypes($data['itemtypes']); - if (in_array($itemtype, $dataitemtypes)) { + if (in_array($itemtype, $dataitemtypes) && Session::haveAccessToEntity($data['entities_id'], $data['is_recursive'])) { $id = $data['id']; //profiles restriction if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] != null && $id > 0) {