Skip to content

Conversation

@gkleen
Copy link

@gkleen gkleen commented Oct 26, 2021

When resolving saved searches while creating dashboards from initialdata the same sql-query-object was reused.
Therefore the resulting sql query accumulated limits (composed with OR), returning false positives to …->First.

Consider the following excerpt from our logs:

2021-10-25 14:48:32.645 UTC [4658] rt@rt5 LOG:  statement: SELECT main.* FROM Attributes main  WHERE (main.Description = '[_1] highest priority tickets I own') AND (main.ObjectId = 1) AND (main.ObjectType = 'RT::System')  ORDER BY main.id ASC 
2021-10-25 14:48:32.647 UTC [4658] rt@rt5 LOG:  statement: SELECT main.* FROM Attributes main  WHERE (main.Description = '[_1] highest priority tickets I own' OR main.Description = '[_1] newest unowned tickets') AND (main.ObjectId = 1) AND (main.ObjectType = 'RT::System')  ORDER BY main.id ASC 
2021-10-25 14:48:32.648 UTC [4658] rt@rt5 LOG:  statement: SELECT main.* FROM Attributes main  WHERE (main.Description = '[_1] highest priority tickets I own' OR main.Description = '[_1] newest unowned tickets' OR main.Description = 'Bookmarked Tickets') AND (main.ObjectId = 1) AND (main.ObjectType = 'RT::System')  ORDER BY main.id ASC 

The generated queries are obviously wrong.

The Problem lies with sub Attributes { in lib/RT/Record.pm memoizing the returned query object, causing the same object to be reused in every pass through the for-loop, accumulating limits as described above.
This PR Clone()s the query object in every pass through the for-loop, preventing this accumulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant