Patch #14606
closedInternal error when copying an issue + on "my page" in block "assigned to me"
0%
Description
I stumbled upon an issue in the latest svn version of Redmine and have attached a small path for the problem. You might want to look for the root cause of the issue since obviously my fix is probably only a workaround:
- user_ids = [user.id] + user.groups.map(&:id)
+ user_ids = [user.id] + user.groups.map(&:id).reject(&:nil?
$ svn info
Path: .
URL: http://svn.redmine.org/redmine/trunk
Repository Root: http://svn.redmine.org/redmine
Repository UUID: e93f8b46-1217-0410-a6f0-8f06a7374b81
Revision: 12072
Node Kind: directory
Schedule: normal
Last Changed Author: tmaruyama
Last Changed Rev: 12072
Last Changed Date: 2013-08-01 05:31:54 +0200 (Thu, 01 Aug 2013)
Environment:
Redmine version 2.3.2.devel.12072
Ruby version 2.0.0-p247 (2013-06-27) [x86_64-linux]
Rails version 3.2.13
Environment production
Database adapter Mysql2
SCM:
Subversion 1.6.17
Git 1.7.9.5
Filesystem
Redmine plugins:
clipboard_image_paste 1.7
redmine_lightbox 0.0.1
Completed 500 Internal Server Error in 35ms
ActionView::Template::Error (Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')))) OR (projects.id IN (23,1,24,22) AND ((issues.is_private = 0 OR issues.autho' at line 1: SELECT COUNT FROM `issues` LEFT OUTER JOIN `projects` ON `projects`.`id` = `issues`.`project_id` LEFT OUTER JOIN `issue_statuses` ON `issue_statuses`.`id` = `issues`.`status_id` WHERE (((projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking')) AND ((projects.is_public = 1 AND ((issues.is_private = 0 OR issues.author_id = 87 OR issues.assigned_to_id IN (87,85,)))) OR (projects.id IN (23,1,24,22) AND ((issues.is_private = 0 OR issues.author_id = 87 OR issues.assigned_to_id IN (87,85,)))) OR (projects.id IN (20) AND ((issues.is_private = 0 OR issues.author_id = 87 OR issues.assigned_to_id IN (87,85,)))) OR (projects.id IN (21) AND ((issues.is_private = 0 OR issues.author_id = 87 OR issues.assigned_to_id IN (87,85,))))))) AND (issue_statuses.is_closed = 0) AND ((`issues`.`assigned_to_id` IN (87, 85) OR `issues`.`assigned_to_id` IS NULL))):
1: <h3>
2: <%= link_to l(:label_assigned_to_me_issues),
3: issues_path(:set_filter => 1, :assigned_to_id => 'me', :sort => 'priority:desc,updated_on:desc') >
4: (<= Issue.visible.open.where(:assigned_to_id => ([User.current.id] + User.current.group_ids)).count >)
5: </h3>
6:
7: < assigned_issues = issuesassignedtome_items %>
app/views/my/blocks/_issuesassignedtome.html.erb:4:in `_app_views_my_blocks__issuesassignedtome_html_erb___3305484256914345155_39797900'
app/views/my/page.html.erb:11:in `block in app_views_my_page_html_erb_2950117810366781438_39717000'
app/views/my/page.html.erb:8:in `each'
app/views/my/page.html.erb:8:in `_app_views_my_page_html_erb__2950117810366781438_39717000'
Files
Related issues
Updated by Jean-Philippe Lang over 11 years ago
I can't see how it can happen. Do you have any plugins installed?
Updated by Mattanja Kern over 11 years ago
Jean-Philippe Lang wrote:
I can't see how it can happen. Do you have any plugins installed?
Plugins are listed above:
clipboard_image_paste 1.7
redmine_lightbox 0.0.1
I don't think it's related to plugins though. One possibility would be corrupt data in the database because the database has a history of Redmine, switched to Chiliproject (because it seemed to be more active at that time ~ two years ago), then switched back to Redmine with some manual fixes to the database structure. I already tried to analyse the users table and the groups_users, groups and members table but could not find the problem. Maybe you can point me to a possible place to look at, then I'll be happy to help trying to reproduce the issue.
Updated by Toshi MARUYAMA over 11 years ago
- Status changed from New to Closed
ChiliProject database is not compatible with Redmine.
Updated by Mattanja Kern over 11 years ago
Toshi MARUYAMA wrote:
ChiliProject database is not compatible with Redmine.
What? Of course it's not! That's why I had to upgrade the structure + fix it. But ok, I will do a precise schema comparison and update the issue again in case that will not resolve it.
Updated by Jean-Philippe Lang over 11 years ago
You must have some rows in the groups_users
table that have an invalid group_id. You can try:
delete from groups_users where group_id not in (select id from users);
and see if any row is deleted.
Updated by Mattanja Kern over 11 years ago
Thanks a lot for your support! The groups_users did not contain invalid entries but after updating the entire database schema by comparing it to a newly created database, the issue seems to be resolved (without the patch of course). Sorry for bothering!
Updated by Thomas Peterson over 11 years ago
I have the same Issue with the latest Git Revision.
delete from groups_users where group_id not in (select id from users); -> deletes nothing
issues.assigned_to_id IN (87,85,) looks wrong but why?
Updated by Mattanja Kern over 11 years ago
yes, different from my previous comment, I experienced the same issue again with an updated database schema. I'm still not sure about the specific set-up responsible for the problem but I'll try to provide a reproducible sample on an empty new Redmine setup later today.
For each group that a user is assigned to I'm getting this "nil" entry in the user.groups.map(&:id)
. (i.e. user assigned to one group results in issues.assigned_to_id IN (87,), when the user is assigned to two groups the result is issues.assigned_to_id IN (87,,).
Updated by Robin Wenglewski over 11 years ago
Mattanja, your solution
user_ids = [user.id] + user.groups.map(&:id).reject(&:nil?)
in self.visible_condition (https://github.com/redmine/redmine/blob/master/app/models/issue.rb#L104) works, however, then you loose the group ids in your condition. The groups are actually loaded, but somehow without an id. I put a
user.reloadafter
when 'default'and
when 'own', which works quite well.
Question is, why are the groups loaded without an id in the first place?
Updated by wooden rob over 11 years ago
I get the same issue when viewing an issue.
The user.reload works fixed it too.
Before reload I get:[58, nil, nil]
After reload I get: [13, 15, 60]
Updated by Toshi MARUYAMA about 11 years ago
- Related to Defect #14939: Wiki link to specific issues failed added