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

Aberta
#399 0 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
Meio dia
Facilidade para iniciantes
62/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
php, sql
Domínio
backend, search

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
PHP
Estrelas
30
Forks
26
Merge médio
1d 2h
PRs com merge (30d)
8

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de pluginsGLPI/tag

Todas as issues de pluginsGLPI/tag

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.