Patch #25265
QueriesController can not handle subclass of IssueQuery
Status: | Closed | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | % Done: | 0% | ||
Category: | Issues filter | |||
Target version: | 4.1.0 |
Description
I have a PivotQuery, it's a subclass of IssueQuery.
But Query don't think it is subclass of himself.
So, r15635 let my plugin down.
I changed QueriesController to fix it.
OLD CODE:
def query_class
Query.get_subclass(params[:type] || 'IssueQuery')
end
New Code
def query_class
get_query_class(params[:type] || 'IssueQuery')
end
def get_query_class(class_name)
klass = nil
begin
klass = class_name.to_s.classify.constantize
rescue
# invalid class name
end
unless klass && klass.new.is_a?(Query)
klass = nil
end
klass
end
Associated revisions
Fixed that QueriesController can not handle subclass of IssueQuery (#25265).
History
#1
Updated by Haihan Ji over 5 years ago
Maybe klass < Query
is better than klass && klass.new.is_a?(Query)
.
#2
Updated by Jean-Philippe Lang over 5 years ago
We should be able to fix get_subclass
instead:
Index: lib/redmine/subclass_factory.rb
===================================================================
--- lib/redmine/subclass_factory.rb (revision 16379)
+++ lib/redmine/subclass_factory.rb (working copy)
@@ -29,7 +29,7 @@
rescue
# invalid class name
end
- unless subclasses.include? klass
+ unless descendants.include? klass
klass = nil
end
klass
Would it work for you?
#3
Updated by Alexander Meindl almost 3 years ago
Hi Jean-Philippe,
your suggested change would be fix problems for some plugins, which I maintain. It would be nice to get this change in a upcoming release.
#4
Updated by Go MAEDA almost 3 years ago
- Assignee set to Jean-Philippe Lang
- Target version set to 4.1.0
#5
Updated by Jean-Philippe Lang almost 3 years ago
- Status changed from New to Closed
#6
Updated by Alexander Meindl over 2 years ago
This change is only available in trunk, but not in Branch 4.1-stable - as this issue shows. Can we get this to 4.1-stable branch?
#7
Updated by Marius BALTEANU over 2 years ago
Alexander Meindl wrote:
This change is only available in trunk, but not in Branch 4.1-stable - as this issue shows. Can we get this to 4.1-stable branch?
It is already on 4.1-stable branch, pleasee source:branches/4.1-stable/lib/redmine/subclass_factory.rb#L34.
#8
Updated by Alexander Meindl over 2 years ago
You are right! Sorry for bothering you about this.