プロジェクト

全般

プロフィール

Vote #78297

完了

QueriesController can not handle subclass of IssueQuery

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Issues filter_56
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
56
version_id:
127
issue_org_id:
25265
author_id:
102443
assigned_to_id:
1
comments:
8
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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

journals

Maybe %{color:red}@klass < Query@% is better than %{color:red}@klass && klass.new.is_a?(Query)@%.
--------------------------------------------------------------------------------
We should be able to fix @get_subclass@ instead:

<pre><code class="diff">
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
</code></pre>

Would it work for you?
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
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?
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
You are right! Sorry for bothering you about this.
--------------------------------------------------------------------------------

Admin Redmine さんが4年以上前に更新

  • カテゴリIssues filter_56 にセット
  • 対象バージョン4.1.0_127 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0