Redmine - Defect #27153
Custom query breaks calendar view with error 500
2017-10-10 10:44 - Bernhard Rohloff

ステータス:

Closed

開始日:

優先度:

Normal

期日:担当者:

Jean-Philippe Lang

進捗率:0%

カテゴリ:

Calendar

予定工数:0.00時間対象バージョン:3.4.4

Resolution:

Fixed

Affected version:

3.4.2

説明
When the custom query includes a second sort criteria the calendar view breaks with an error 500.
Steps to reproduction:
1. Create a custom query with a second sort criteria
2. Select the custom query in the calendar view
This results into:!Screenshot-2017-10-10 500 - Redmine.png!
関連するチケット:
次のチケットが重複 Redmine - Defect #26544: SQL-Error occurs somet...

Closed

関係しているリビジョン
リビジョン 17155 - 2018-01-07 23:28 - Jean-Philippe Lang
Custom query breaks calendar view with error 500 (#27153).
Patch by Bernhard Rohloff.
リビジョン 17156 - 2018-01-07 23:28 - Jean-Philippe Lang
Adds tests for #27153.
Patch by Marius BALTEANU.
リビジョン 17157 - 2018-01-07 23:29 - Jean-Philippe Lang
Merged r17155 and r17156 to 3.4-stable (#27153).

履歴#1 - 2017-10-10 14:08 - Toshi MARUYAMA- ステータス を New から Needs feedback に変更
Please see submissions.
#2 - 2017-10-10 15:55 - Bernhard Rohloff- ファイル calendar̲error500̲production̲bitnami.log を追加- ファイル calendar̲error500̲production̲trunk.log を追加
Sorry for the useless screenshot. It's obvious that this error message was worth nothing...
I've experienced this issue on three separate Redmine instances.
A Bitnami VM V3.4.2 a manual installation with V3.4.2 and a development installation (trunk r16970).
You can find the production logs for the Bitnami VM and the trunk installation in the attachments.
Bitnami Environment:

Environment:

2024-09-09

1/5

Redmine version
Ruby version
Rails version
Environment
Database adapter
SCM:
Subversion
Cvs
Filesystem
Redmine plugins:
clipboard̲image̲paste
redmine̲custom̲macros
redmine̲lightbox2

3.4.2.stable
2.3.4-p301 (2017-03-30)
4.2.8
production
Mysql2[x86̲64-linux]

1.9.7
1.12.13

1.12
0.0.1
0.4.3

Trunk Installation:

Environment:
Redmine version
Ruby version
Rails version
Environment
Database adapter
SCM:
Subversion
Mercurial
BazaarGit
Filesystem
Redmine plugins:no plugin installed#3 - 2017-10-10 16:06 - Marius B3.4.2.devel.16970
2.2.7-p470 (2017-03-28)
5.1.2
production
Mysql2[x86̲64-linux]

1.6.11
2.2.2
2.1.1
2.7.4

LTEANUThe same error was reported in #26544.
#4 - 2017-10-10 16:28 - Bernhard Rohloff
Yes, this seems to be the same error.
On all my installations it is 100% reproducible.
These cases I've tested right now:Standard view (no filters) --> works
Custom query (standard view) with single sort criteria --> works
Custom query (standard view) with second sort criteria --> fails
MySQL Versions
Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86̲64) using readline 5.1 (trunk version)
Ver 14.14 Distrib 5.6.37, for linux-glibc2.12 (x86̲64) using EditLine wrapper (Bitnami V3.4.2.stable)#5 - 2017-10-12 03:03 - Go MAEDA- ステータス を Needs feedback から Confirmed に変更- 対象バージョン を 3.4.3 にセット
I confirmed the problem. 3.4-stable and trunk are affected by the problem. No problem in 3.3-stable.
According to the result of ̀git bisect̀, r16390 caused the problem.
#6 - 2017-10-12 06:11 - Bernhard Rohloff
That's right. r16390 is the bad revisison. I wrote my debugging results in #26544#note-28, yesterday. The issue seems to be a duplicate and there
are more guys affected by this in #26544. I also wrote two possible workarounds there, but until now, there isn't any feedback on it. Because there
are two slightly different ways to fix this, I'm a bit double-minded for which solution I should create a patch.
#7 - 2017-10-12 09:26 - Marius BLTEANU- 次のチケットが重複 Defect #26544: SQL-Error occurs sometimes when clicking on "calendar" tab を追加#8 - 2017-10-12 10:55 - Bernhard Rohloff- ファイル calendars̲order̲error̲500̲cleanup.diff を追加- ファイル calendars̲order̲error̲500̲quick.diff を追加

2024-09-09

2/5

I've made a patch with the second solution of my fixing proposals in #26544#note-28. Although it's not my prefered solution, it fits more to theworkaround JP made in r3379.
To fix it in a cleaner way, you would have to modify the issues method in app/models/issue̲query.rb which could break other modules (Gantt) and I
have no clue how the method is intended to work.

# Returns the issues ids# Valid options are :order, :offset, :limit, :include, :conditions
def issue̲ids(options={})order̲option = [group̲by̲sort̲order, (options[:order] ¦¦ sort̲clause)].flatten.reject(&:blank?)
scope = Issue.visible.
...
To make the choice of order (query or options) explicit would make more sense to me.
In this case we could remove the ugly workarounds in app/controllers/calendards̲controller.rb and app/controllers/gantts̲controller.rb (where itworks already, because there are :order options).

# Returns the issues# Valid options are :order, :offset, :limit, :include, :conditions
def issues(options={})order̲option = ([options[:order]] ¦¦ [group̲by̲sort̲order, sort̲clause]).flatten.reject(&:blank?)
scope = Issue.visible.
...
I've attached both patches, so you can choose which fits best.
Cheers!
PS: As far as I was able to test it, Gantt also seems to work well, with the "cleanup" patch.
#9 - 2017-10-15 13:33 - Jean-Philippe Lang
- 対象バージョン を 3.4.3 から 3.4.4 に変更
Can we add a failing test in the patch?
#10 - 2017-10-16 00:12 - Marius B

LTEANU- ファイル tests̲for̲custom̲query̲breaks̲calendar̲view.patch を追加
Jean-Philippe Lang wrote:
Can we add a failing test in the patch?

Here is a patch with two failing tests.
#11 - 2017-10-31 11:14 - 匿名ユーザー
For information, this issue is triggered on all issues by the Issue Hot Buttons plugin in redmine 3.4.2 because of the way it adds "previous/next"
buttons on issues:module IssueHotButtons
module IssuesControllerPatchdef self.included(base)base.send(:helper, :sort)base.send(:include, SortHelper)
base.send(:include, InstanceMethods)
base.class̲eval do
before̲filter :nearby̲issues, :only => :show
before̲filter :store̲last̲seen̲project, :only => :index
end
end
module InstanceMethods
def nearby̲issues
restore̲project = nilunless session[:last̲seen̲project].nil?
last̲seen̲project = Project.find(session[:last̲seen̲project])
if @project.self̲and̲ancestors.include? last̲seen̲project2024-09-09

3/5

restore̲project = @project@project = last̲seen̲project
end
end
session['issues̲show̲sort'] = session['issues̲index̲sort'] unless session['issues̲index̲sort'].nil?
retrieve̲querysort̲init(@query.sort̲criteria.empty? ? [['id', 'desc']] : @query.sort̲criteria)sort̲update(@query.sortable̲columns)@nearby̲issues = [];if @query.valid?
@issues = @query.issues(:include => [:assigned̲to, :tracker, :priority, :category, :fixed̲version],:order => sort̲clause)@issues.uniq!
@issues.each {¦issue¦ @nearby̲issues.push issue.id}
end@project = restore̲project unless restore̲project.nil?
end
def store̲last̲seen̲project
session[:last̲seen̲project] = @project.id unless @project.nil?
end
end
end
end
If that's somewhat standard, this issue might trigger for other plugins too.
#12 - 2018-01-07 23:29 - Jean-Philippe Lang- ステータス を Confirmed から Closed に変更- 担当者 を Jean-Philippe Lang にセット
- Resolution を Fixed にセット
Fix applied with the tests, thanks.
#13 - 2018-06-03 23:19 - Matthew Paul
Addition here for anyone having the same problem and can't or doesn't want to upgrade. The issue is, indeed, the issue̲hot̲buttons plugin (or atleast it was for me). Which is a really useful addition to redmine that I didn't want to lose. So the easy fix is right here https://github.com/Silex/issue̲hot̲buttons/commit/069c4bf89c8626475566d3e40d3a45fe3f2d53f0
You can simply delete 3 lines from the plugin init.rb and then replace the issue̲controller̲patch.rb in the plugin with the one from that link above.
So, this fix hasn't been merged into the main plugin code which is here https://github.com/panicinc/issue̲hot̲buttons...or at least I don't think it has. So that's why I wanted to take the most advanced version from panicinc and add the fix from Silex. Full disclosure I'm clueless at ruby/rails etc - so a) this might not be the correct way to do this and b) if I can do it then anyone can.
(Thanks to the plugin developers and as always to Jean-Philippe Lang who is a God as far as I'm concerned - Redmine is so far and away better thanJira, Service Now, and anything else, it's actually comical. Trying to explain it to people who immediately say 'oh it's a bug tracker' and I just shake
my head because it is SO much more).
#14 - 2018-06-18 15:37 - Nikita Remizov
Created issue in issue̲hot̲buttons plugin https://github.com/panicinc/issue̲hot̲buttons/issues/15#15 - 2019-03-29 22:08 - Matthew Paul
Additional info - for anyone who navs here, and uses teh hot buttons plugin. This can cause problems which may suddenly appear and not go away.
This is because of the issue I mentioned above but now in some of the versions the fix doesn't work. If you want to do a quick and dirty fix just do
this .../plugins/issue̲hot̲buttons/lib/issues̲controller̲patch.rb Line 33 or thereabouts...
@issues#WAS=@query.issues(:include => [:assigned̲to, :tracker, :priority, :category, :fixed̲version],:include => [:assigned̲to, :tracker, :category, :fixed̲version],

2024-09-09

4/5

:order=>sort̲clause)That's it - just get rid of the priority, which removes the double join on the enumerations table, and seems to fix things.

ファイル
Screenshot-2017-10-10 500 - Redmine.png

13.7 KB

2017-10-10

Bernhard Rohloffcalendar̲error500̲production̲trunk.log

3.95 KB

2017-10-10

Bernhard Rohloff

calendar̲error500̲production̲bitnami.log

4.63 KB

2017-10-10

Bernhard Rohloff

calendars̲order̲error̲500̲quick.diff557 Bytes

2017-10-12

Bernhard Rohloff

calendars̲order̲error̲500̲cleanup.diff

2.13 KB

2017-10-12

Bernhard Rohloff

tests̲for̲custom̲query̲breaks̲calendar̲view.patch

1.1 KB2017-10-15

Marius B

2024-09-09

5/5

LTEANU