Tags search criterion returns items of other itemtypes that share the same ID

Offen
#399 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
Ein halber Tag
Anfängerfreundlichkeit
62/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
php, sql
Bereich
backend, search

Rechercherichtung

The bug is in the search option for tags, built in plugin_tag_getAddSearchOptionsNew(). Compare its joinparams with the regular join, since the generated subquery keeps only condition and drops jointype and specific_itemtype. Reproduce with a tag on a Project and a ProjectTask that share an ID, then check that a 'Tags is' search on projects excludes the project. Done when the search returns only items of the searched itemtype and 'is not' behaves correctly.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

GLPI 11.0.11, Tag 2.14.8.

Searching projects with "Tags is ASYS" returns project 80, which only has the tag DNS. Project task 80 has the tag ASYS.

Since use_subquery is set for GLPI >= 10.0.19, the criterion is built as a subquery by Glpi\Search\Provider\SQLProvider. The subquery only keeps joinparams['condition'] of the glpi_plugin_tag_tagitems join and ignores jointype => itemtype_item / specific_itemtype, so there is no filter on itemtype:

`glpi_projects`.`id` IN (SELECT `items_id` FROM `glpi_plugin_tag_tagitems` WHERE true AND `plugin_tag_tags_id` = '111')

Any item of any type with the same ID and the tag matches. With "is not", the item is wrongly excluded. It happens on every itemtype as soon as a tag is used on more than one type (tickets, changes, computers...). The Tags column in the results is correct, the regular LEFT JOIN has the itemtype condition.

Steps to reproduce:

  1. Allow a tag on Project and ProjectTask.
  2. Put the tag on a project task whose ID is also the ID of an untagged project.
  3. Search projects with "Tags is ": the project is returned.

Adding the itemtype as a join condition in plugin_tag_getAddSearchOptionsNew() fixes it, since the subquery keeps condition:

'jointype'          => 'itemtype_item',
'specific_itemtype' => $itemtype,
'condition'         => ['NEWTABLE.itemtype' => $itemtype],

We run this patch locally. The core subquery could also handle itemtype_item itself.

Vorherrschende Sprache
PHP
Sterne
30
Forks
26
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
8

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus pluginsGLPI/tag

Alle Issues in pluginsGLPI/tag

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.