maxrossello / redmine_app_timesheets

A true timesheet plugin using orders, not bound to timelogs over issues
GNU General Public License v2.0
32 stars 10 forks source link

Error when showing project (ver1.5 + PostgreSQL + Shared versions visible: false) #47

Closed greyman888 closed 9 years ago

greyman888 commented 9 years ago

Hi Max,

The biggest bug I've found with Ver1.5 occurs with the following environment:

Timesheet Settings:

When selecting any project to view it, this is what happens:

Started GET "/projects/work-project" for 115.42.16.233 at 2015-03-10 00:59:50 +0000
Processing by ProjectsController#show as HTML
  Parameters: {"id"=>"work-project"}
<snip> 

it starts OK and gets through here as well:

<snip>
Rendered projects/_members_box.html.erb (0.1ms)
Rendered projects/_sidebar.html.erb (0.7ms)
Rendered projects/show.html.erb within layouts/base (14.0ms)

And then the error seems to occur when rendering the menus:


  UserPreference Load (0.5ms)  SELECT  "user_preferences".* FROM "user_preferences" WHERE "user_preferen es"."user_id" = $1 LIMIT 1  [["user_id", 1]]
  Project Load (0.5ms)  SELECT "projects"."id", "projects"."name", "projects"."identifier", "projects"."lft", "projects"."rgt" FROM "projects" INNER JOIN "members" ON "projects"."id" = "members"."project_id" WHERE "members"."user_id" = $1 AND (projects.status<>9) AND "projects"."status" = $2  ORDER BY projects.name  [["user_id", 1], ["status", 1]]
  Group Load (0.5ms)  SELECT "users".* FROM "users" INNER JOIN "groups_users" ON "users"."id" = "groups_users"."group_id" WHERE "users"."type" IN ('Group', 'GroupBuiltin', 'GroupAnonymous', 'GroupNonMember') AND "groups_users"."user_id" = $1  [["user_id", 1]]
  TsPermission Load (1.4ms)  SELECT DISTINCT "ts_permissions".* FROM "ts_permissions" WHERE "ts_permissions"."order_id" IN (SELECT "versions"."id" FROM "versions" INNER JOIN "projects" ON "projects"."id" = "versions"."project_id" WHERE (projects.id = 2 OR (projects.status <> 9 AND ( versions.sharing = 'system' OR (projects.lft >= 3 AND projects.rgt <= 4 AND versions.sharing = 'tree') OR (projects.lft < 3 AND projects.rgt > 4 AND versions.sharing IN ('hierarchy', 'descendants')) OR (projects.lft > 3 AND projects.rgt < 4 AND versions.sharing = 'hierarchy'))))) AND "ts_permissions"."is_primary" = 't' AND "ts_permissions"."principal_id" IN (1, 3)
   (1.6ms)  SELECT COUNT(*) FROM "versions" INNER JOIN "projects" ON "projects"."id" = "versions"."project_id" WHERE (projects.id = 2 OR (projects.status <> 9 AND ( versions.sharing = 'system' OR (projects.lft >= 3 AND projects.rgt <= 4 AND versions.sharing = 'tree') OR (projects.lft < 3 AND projects.rgt > 4 AND versions.sharing IN ('hierarchy', 'descendants')) OR (projects.lft > 3 AND projects.rgt < 4 AND versions.sharing = 'hierarchy')))) AND ((versions.project_id = 1 AND versions.id IN (NULL))
                                                  OR (versions.project_id != 1 AND versions.project_id IN (SELECT "projects".* FROM "projects" WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking')))))
PG::SyntaxError: ERROR:  subquery has too many columns
LINE 2: ...(versions.project_id != 1 AND versions.project_id IN (SELECT...
                                                             ^
: SELECT COUNT(*) FROM "versions" INNER JOIN "projects" ON "projects"."id" = "versions"."project_id" WHERE (projects.id = 2 OR (projects.status <> 9 AND ( versions.sharing = 'system' OR (projects.lft >= 3 AND projects.rgt <= 4 AND versions.sharing = 'tree') OR (projects.lft < 3 AND projects.rgt > 4 AND versions.sharing IN ('hierarchy', 'descendants')) OR (projects.lft > 3 AND projects.rgt < 4 AND versions.sharing = 'hierarchy')))) AND ((versions.project_id = 1 AND versions.id IN (NULL))
                                                  OR (versions.project_id != 1 AND versions.project_id IN (SELECT "projects".* FROM "projects" WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking')))))
Completed 500 Internal Server Error in 128ms

The extracted source from the error message rendered to the screen is:

Extracted source (around line #230):   
228   menu.push :activity, { :controller => 'activities', :action => 'index' }
229   menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
230               :if => Proc.new { |p| p.shared_versions.any? }
231   menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
232   menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
233               :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) },

We are currently running in production Redmine 2.6 + PostgreSQL + timesheet 1.3.28 so it might be that this was a problem introduced in timesheet 1.4 that we never experienced.

Sorry to be a pain. Let me know if there is anything I can do to help resolve this.

Adam

maxrossello commented 9 years ago

The problem seems to have a blocking effect in rails 4 only, but I backported it to 1.3 branch as well

greyman888 commented 9 years ago

Thanks again.