Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

TypeError in search on GLPI 12: "Tags - Entity" search option uses a string join condition

Đang mở Phù hợp với người mới
#389 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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
90/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
Lĩnh vực
backend

Hướng nghiên cứu

Mở hook.php và định vị plugin_tag_getAddSearchOptionsNew(), cụ thể là tùy chọn tìm kiếm có id 10501 với joinparams condition được đặt thành chuỗi "AND 1=1". Thay thế nó bằng một \Glpi\DBAL\QueryExpression bọc trong mảng như hiển thị trong diff gợi ý của issue, giữ lại nhận xét giải thích tại sao điều kiện này tồn tại. Xác minh bằng cách thêm cột "Tags - Entity" vào danh sách Ticket trong một instance GLPI 12 và xác nhận không có TypeError của analyseCrit() nào xuất hiện; kiểm tra xem có bài kiểm thử của plugin hoặc mục CHANGELOG nào cần cập nhật không.

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

Mô tả

Description

After upgrading to GLPI 12.0.0 with tag 2.15.0, every search that includes the "Tags - Entity" search option (id 10501) fails. This breaks the ticket list, dashboard cards based on saved searches, and saved search alerts (cron).

GLPI 12 no longer accepts a raw SQL string as join condition: DBmysqlIterator::analyseCrit() is now typed array $crit.

Steps to reproduce

  1. GLPI 12.0.0, tag plugin 2.15.0
  2. Add the "Tags - Entity" column (search option 10501) to the Ticket list display
  3. Open the ticket list (or any dashboard card / saved search on Ticket)

Error

glpi.CRITICAL: *** Uncaught PHP Exception TypeError: "DBmysqlIterator::analyseCrit(): Argument #1 ($crit) must be of type array, string given, called in ./src/DBmysqlIterator.php on line 602"
  ./src/DBmysqlIterator.php:602              DBmysqlIterator->analyseCrit()
  ./src/DBmysqlIterator.php:820              DBmysqlIterator->analyseCrit()
  ./src/DBmysqlIterator.php:612              DBmysqlIterator->analyseFkey()
  ./src/DBmysqlIterator.php:767              DBmysqlIterator->analyseCrit()
  ./src/DBmysqlIterator.php:327              DBmysqlIterator->analyseJoins()
  ./src/Glpi/DBAL/Parts/BasePart.php:64      DBmysqlIterator->buildQuery()
  ./src/Search.php:710                       Glpi\DBAL\Parts\BasePart->withCriteria()
  ./src/Glpi/Search/Provider/SQLProvider.php:4867  Search::addLeftJoin()
  ./src/Search.php:263                       Glpi\Search\Provider\SQLProvider::constructSQL()
  ./src/SavedSearch.php:1154                 Search::constructSQL()

Cause

hook.php, in plugin_tag_getAddSearchOptionsNew():

'joinparams'    =>  [
    'condition'  => "AND 1=1", // to force distinct complex id than the previous option

Suggested fix

Use an array condition, which keeps the distinct complex id while matching the GLPI 12 API:

-                    'condition'  => "AND 1=1", // to force distinct complex id than the previous option
+                    'condition'  => [new \Glpi\DBAL\QueryExpression('1=1')], // to force distinct complex id than the previous option

We applied this patch locally: the ticket list and dashboard cards work again.

Environment

  • GLPI 12.0.0 (official Docker image ghcr.io/glpi-project/glpi:12.0.0)
  • tag 2.15.0
  • PHP 8.x, MariaDB 11.8
Ngôn ngữ chính
PHP
Star
29
Fork
26
Merge trung bình
1 ngày 5 giờ
Pull request đã merge (30 ngày)
10

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

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

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/tag

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

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.