Project

General

Profile

Actions

Defect #11662

closed

Invalid query returned from Issues.visible scope after accessing User#projects_by_role with a role that is not present

Added by Joe Rocklin over 11 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

I was seeing an issue with some users getting a 500 error from their 'My Page' view. The stack trace showed a mysql query error, with the offending part being:

... OR projects.id IN () ...

After some digging I discovered the problem was entering from the Project.allowed_to_condition when looping of the user.project_by_role list the user didn't have any projects specified with the given role. See attached patch.

rake about output:
About your application's environment
Ruby version 1.9.3 (x86_64-linux)
RubyGems version 1.8.24
Rack version 1.4
Rails version 3.2.6
Active Record version 3.2.6
Action Pack version 3.2.6
Active Resource version 3.2.6
Action Mailer version 3.2.6
Active Support version 3.2.6
Middleware Rack::Cache, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000002271f30>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, RedmineDmsf::NoParse, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport, OpenIdAuthentication
Application root /opt/redmine
Environment production
Database adapter mysql2
Database schema version 20120422150750


Files

fix_empty_project.patch (598 Bytes) fix_empty_project.patch exclude conditions for a role if the user has no projects with that role Joe Rocklin, 2012-08-20 19:53
Actions

Also available in: Atom PDF