Error when running "Likes" report

When running the “Likes” admin report, I’m getting an error when filtering by a category. The error does not appear, and the report returns expected data when not filtering by a category.

The message in the logs is:

Error while computing report `likes`: undefined method `in_category_and_categories' for #<Class:0x00007f598e06c5b8>

The trace is:

Summary
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/logster-1.2.11/lib/logster/logger.rb:94:in `add_with_opts'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/logster-1.2.11/lib/logster/logger.rb:51:in `add'
/usr/local/lib/ruby/2.5.0/logger.rb:545:in `error'
/var/www/discourse/app/models/report.rb:191:in `rescue in find'
/var/www/discourse/app/models/report.rb:161:in `find'
/var/www/discourse/app/controllers/admin/reports_controller.rb:36:in `block (2 levels) in bulk'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/strong_parameters.rb:338:in `block in each_pair'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/strong_parameters.rb:337:in `each_pair'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/strong_parameters.rb:337:in `each_pair'
/var/www/discourse/app/controllers/admin/reports_controller.rb:25:in `block in bulk'
/var/www/discourse/lib/hijack.rb:56:in `instance_eval'
/var/www/discourse/lib/hijack.rb:56:in `block in hijack'
/var/www/discourse/lib/scheduler/defer.rb:70:in `block in do_work'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rails_multisite-2.0.4/lib/rails_multisite/connection_management.rb:63:in `with_connection'
/var/www/discourse/lib/scheduler/defer.rb:68:in `do_work'
/var/www/discourse/lib/scheduler/defer.rb:59:in `block (2 levels) in start_thread'
3 Likes

I can repro this here on Meta. Something for your list @joffreyjaffeux?

2 Likes

Seems like there was a typo in @misaka4e21 commit: https://github.com/discourse/discourse/commit/6db623ef6b489d1c55561846722a86bf39a992d0#diff-b24ed94384243f273e73d5c785d02106R146

in_category_and_categories instead of in_category_and_subcategories

I fixed it in:
https://github.com/discourse/discourse/pull/6439

If you are around @misaka4e21 can you confirm it was your initial intent? Otherwise I will merge this at the end of the day.

8 Likes

Sorry, it’s my mistake. Please merge that fix.

6 Likes

Absolutely no worries :+1: Thanks for checking.

4 Likes