FIX: Negative limit values shouldn't cause error 500 (PR #10162)

This PR fixes errors such as:

PG::InvalidRowCountInLimitClause (ERROR:  LIMIT must not be negative
)
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-2.0.2/lib/patches/db/pg.rb:110:in `exec'

when /tags/filter/search endpoint is hit with a negative limit param.

GitHub

I wonder, is that the only spot where we have a limit parameter?

From a quick grep for :limit in app/controllers, I can see about 5 or 6 controllers that may have this issue. I can open a new PR for them and fix them if you’d like me to do that or wait until we see this issue from those controllers in our logs, just let me know what you prefer :smile_cat:

Let’s wait till it hurt.