From 82e0c76281bf1e068b6e7a460d714659fb60c3e0 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 | 6 ++++++ inc/container.class.php | 10 ++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a969e098..e019bcc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [UNRELEASED] + +### Fixed + +- Optimize container loading when there are a large number of entities + ## [1.24.0] - 2026-04-16 ### Added diff --git a/inc/container.class.php b/inc/container.class.php index 6968024f..3549cd63 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) {