Defect #17881

Javascript error when displaying a saved query with some defined filters omitted from the available_filters

Added by Holger Just about 3 years ago. Updated about 3 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Baptiste Barth% Done:

0%

Category:Issues
Target version:-
Resolution:Duplicate Affected version:

Description

Attached to this issue, there is a fix for an issue that can occur if a users defines a query in another scope than where it is ultimately displayed. If the query define a filter which is not available in the current scope, rendering the filters form will throw a Javascript error resulting in a halt of Javascript execution on the respective page.

In our case at Planio, we had a query that was defined on all projects. The query had a filter of project_id. Now, the project_id is only valid outside of a project. If the query is run inside of a project, the project_id filter will not be added to the available_filters. However, the defined filter is still attempted to be rendered, as the view just loops over all defined filters in the query. This results in a javascript error as during rendering in the browser, the filter can not be added as it is not included in available filters.

The attached patch fixes this issue. It ensures that only those filters are attempted to be rendered that are actually available in the current scope. This fixes the Javascript error.

0001-Render-only-issue-filters-which-are-available-in-the.patch Magnifier (906 Bytes) Holger Just, 2014-09-15 14:11

History

#1 Updated by Jan from Planio www.plan.io about 3 years ago

  • Status changed from New to Resolved
  • Assignee set to Jean-Baptiste Barth
  • Target version set to Candidate for next minor release

Here's another fresh and easy one, Jean-Baptiste, if you like.

#2 Updated by Jean-Baptiste Barth about 3 years ago

No problem merging that, seems reasonable, but I don't reproduce the problem on my 2.5.2 instance. Say I have a project with id 1, I define a query on the cross-projects issue page with a condition on project_id = 1. When I go to the project (or an other one), the "addFilter" line is present for sure, but it doesn't break and looks like valid JS. Am I missing something ?

I'd just like to understand the problem and the conditions in which it occurs. And maybe write a tiny test as a documentation for the future.

Thanks!

#3 Updated by Holger Just about 3 years ago

After some deeper investigation, it turns out, that this is a duplicate of #15190 and thus already fixed in Redmine. I guess, we can close this issue...

#4 Updated by Jan from Planio www.plan.io about 3 years ago

  • Tracker changed from Patch to Defect
  • Status changed from Resolved to Closed
  • Target version deleted (Candidate for next minor release)
  • Resolution set to Duplicate

sorry for the fuss...

Also available in: Atom PDF