Project

General

Profile

Actions

Defect #10879

closed

Searching user causes 500 internal error

Added by Matthias Lindhorst almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Administration
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

Hi Guys,

upgrading from 1.2.1 to 1.4.1 worked like a charm, except for one thing.
Whenever searching for a user (calling UserController#index with a search param) I get a 500 internal error.

The log says:

Processing UsersController#index (for xxx.xxx.xxx.xxx at 2012-05-10 18:26:29) [GET]
Parameters: {"name"=>"xyz", "action"=>"index", "group_id"=>"", "controller"=>"users", "status"=>"1"}

NoMethodError (undefined method `call' for nil:NilClass):
app/controllers/users_controller.rb:44:in `index'
passenger (3.0.12) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.12) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.12) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
passenger (3.0.12) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
passenger (3.0.12) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
passenger (3.0.12) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
passenger (3.0.12) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.12) helper-scripts/passenger-spawn-server:99

Rendering /xxxx/xxxx/xxxx/xxxx/xxxx/xxxx/public/500.html (500 Internal Server Error)

Line 44 of the UsersCoontroller calls the "like" scope of the User model, so i reproduced that call in my rails console resulting in the same error:

u = u.like('mlindh')
NoMethodError: undefined method `call' for nil:NilClass
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:103:in `like'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:186:in `send'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:186:in `method_missing'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/base.rb:2182:in `with_scope'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:118:in `__send__'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:118:in `with_scope'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:179:in `method_missing'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:186:in `send'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:186:in `method_missing'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/base.rb:2182:in `with_scope'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:118:in `__send__'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:118:in `with_scope'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:118:in `__send__'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:118:in `with_scope'
from /xxx/xxx/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-2.3.14/lib/active_record/named_scope.rb:179:in `method_missing'
from (irb):2

As you can see in the log I used Passenger 3.0.12 and the following gems are installed:

gem list

LOCAL GEMS

actionmailer (2.3.14)
actionpack (2.3.14)
activerecord (2.3.14)
activeresource (2.3.14)
activesupport (2.3.14)
bundler (1.1.3)
coderay (1.0.6)
edavis10-object_daddy (0.4.3)
fastercsv (1.5.4)
i18n (0.4.2)
json (1.7.1, 1.7.0)
metaclass (0.0.1)
mocha (0.11.4, 0.11.3)
mysql (2.8.1)
net-ldap (0.3.1)
pg (0.13.2)
rack (1.1.3)
rails (2.3.14)
rake (0.9.2.2)
rdoc (3.12)
rmagick (2.13.1)
ruby-openid (2.1.8)
rubygems-bundler (0.9.0)
rvm (1.11.3.3)
shoulda (2.10.3)
sqlite3 (1.3.6)
tzinfo (0.3.33)

I think this behaviour may be related to Issue #10836 .

Kind regards
Matthias

Actions #1

Updated by Jean-Philippe Lang almost 12 years ago

I really can't reproduce with the same ruby version. It looks like the like scope is lost for User.
Can you try the 3 following commands in the console:

User.like('foo').any?

User.active.like('foo').any?

Principal.active.like('foo').any?
Actions #2

Updated by Matthias Lindhorst almost 12 years ago

Hi Jean-Phillippe, thanks for your answer.

The output shows the following:

User.like('foo').any?
NoMethodError: undefined method `call' for nil:NilClass
from /gems/activerecord-2.3.14/lib/active_record/named_scope.rb:103:in `like'
from (irb):4
User.active.like('foo').any?
NoMethodError: undefined method `call' for nil:NilClass
from /gems/activerecord-2.3.14/lib/active_record/named_scope.rb:103:in `like'
from /gems/activerecord-2.3.14/lib/active_record/named_scope.rb:186:in `send'
from /gems/activerecord-2.3.14/lib/active_record/named_scope.rb:186:in `method_missing'
from /gems/activerecord-2.3.14/lib/active_record/base.rb:2182:in `with_scope'
from /gems/activerecord-2.3.14/lib/active_record/named_scope.rb:118:in `__send__'
from /gems/activerecord-2.3.14/lib/active_record/named_scope.rb:118:in `with_scope'
from /gems/activerecord-2.3.14/lib/active_record/named_scope.rb:179:in `method_missing'
from (irb):5
Principal.active.like('foo').any?
=> false
Principal.active.like('mli').any?
=> true

It seems, that the scope "like" is not present in the User model, although it has been defined in the parent Participation model.
Strange thing...

Actions #3

Updated by Matthias Lindhorst almost 12 years ago

Okay, adding

named_scope :like, lambda {|q|
    if q.blank?
      {}
    else
      q = q.to_s.downcase
      pattern = "%#{q}%" 
      sql = "LOWER(login) LIKE :p OR LOWER(firstname) LIKE :p OR LOWER(lastname) LIKE :p OR LOWER(mail) LIKE :p" 
      params = {:p => pattern}
      if q =~ /^(.+)\s+(.+)$/
        a, b = "#{$1}%", "#{$2}%" 
        sql << " OR (LOWER(firstname) LIKE :a AND LOWER(lastname) LIKE :b) OR (LOWER(firstname) LIKE :b AND LOWER(lastname) LIKE :a)" 
        params.merge!(:a => a, :b => b)
      end
      Rails.logger.info "CONDITIONS: #{[sql, params].inspect}" 
      {:conditions => [sql, params]}
    end
}

to the User model fixes the problem for the moment...

Actions #4

Updated by Jean-Philippe Lang almost 12 years ago

Thanks for the feedback. I can't figure out why I'm not getting this error, do you have any plugins installed?

Actions #5

Updated by Matthias Lindhorst almost 12 years ago

Ah, good point, I almost forgot that!

Currently a fork of the LocalAvatar plugin is installed: https://github.com/dseifert/redmine_local_avatars .

Actions #6

Updated by Matthias Lindhorst almost 12 years ago

  • Status changed from New to Resolved

Okay, uninstalling LocalAvatars revealed, that this plugin somehow causes the problem.
Since this is no direct Redmine issue anymore I will set it to resolved.

Thank you for your help!

Actions #7

Updated by Etienne Massip almost 12 years ago

  • Status changed from Resolved to Closed
Actions #8

Updated by Etienne Massip almost 12 years ago

  • Resolution set to Invalid
Actions #9

Updated by Pavel Potcheptsov almost 12 years ago

Hi. I have same issue after install timesheet and drafts plugins.
It is possible to do something to resolve this?
Or plugin's developers must update their plugins to redmine 1.4.2?

Actions #10

Updated by Etienne Massip almost 12 years ago

Yes, if this appear only when installing a specific plugin then this is this plugin issue.

Actions

Also available in: Atom PDF