Slow page loads with many entities: getEntries() checks entities and rights container by container on every request

Đang mở
#1,347 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@cgrard đang làm issue này rồi.

Từ ngày 12/11/2026.

  • #1348 của @cgrard — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php, sql
Lĩnh vực
backend, performance

Hướng nghiên cứu

Start at plugin_init_fields() and PluginFieldsContainer::getEntries(), then inspect getSonsOf() and PluginFieldsProfile::getRightOnContainer() to trace the per-container work. The issue describes the target behavior: compute visibility once per entity and fetch profile rights for visible containers in one query. Compare results across entities and profiles, then measure getEntries(); done means unchanged visibility and rights with lower request time.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Code of Conduct
  • I agree to follow this project's Code of Conduct
Is there an existing issue for this?
  • I have searched the existing issues
GLPI Version

12.0.1 (same code in the plugin for GLPI 11)

Plugin version

1.25.1 (same code in 1.24.7 on 11.0/bugfixes)

Bug description

plugin_init_fields() calls PluginFieldsContainer::getEntries() on every authenticated request, to register the container tabs. For each active container, getEntries():

  • if the container entity is not one of the active entities, calls getSonsOf() on the container entity and intersects the result with $_SESSION['glpiactiveentities'] using array_intersect();
  • runs one SQL query to get the right of the active profile on the container (PluginFieldsProfile::getRightOnContainer()).

With containers defined on the root entity (recursive) and users working with many active entities, this becomes expensive. Measured on our instance (22 active containers, all on the root entity, 5591 entities, users with up to 1168 or 5591 active entities): getEntries() takes about 47 ms, on every request, including lightweight AJAX calls (ajax/actorinformation.php, ajax/comments.php, ...). array_intersect() alone costs about 3 ms per container, and the same getSonsOf() result is intersected 22 times.

Since a ticket page sends many AJAX calls at once and they are processed one at a time per session (session lock), this cost adds up to several seconds on the last calls.

Steps To reproduce
  1. Create about 20 active tab containers on the root entity, recursive.
  2. Log in with a profile and active entities covering a large entity tree (thousands of entities).
  3. Measure PluginFieldsContainer::getEntries(), or the response time of any AJAX endpoint.
Anything else?

This is the same kind of issue as the one fixed in #1187 for findContainer() / findAllContainers(), but on getEntries(), which runs on every request. A fix is proposed in the linked PR: visibility is computed once per entity, and the rights of the profile on all visible containers are read in a single query. Results are unchanged: on our instance, identical for 39 real user/profile combinations and for the 700 profile × container pairs, and getEntries() goes from about 47 ms to about 2 ms (AJAX call from about 240 ms to about 190 ms).

findAllContainers() still calls getRightOnContainer() in a loop and could reuse the same batched query, but it is not called on every request, so it is left out of the PR.

Ngôn ngữ chính
PHP
Star
122
Fork
85
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
20

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pluginsGLPI/fields

Tất cả issue của pluginsGLPI/fields

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.