mirror of
https://github.com/discourse/discourse.git
synced 2026-08-12 05:55:39 -05:00
PERF: bail out of expensive post validations
Whenever a post already failed "lightweight" validations, we skip all the expensive validations (that cooks the post or run SQL queries) so that we reply as soon as possible. Also skip validating polls when there's no "[/poll]" in the raw. Internal ref - t/115890
This commit is contained in:
@@ -318,6 +318,9 @@ class DiscoursePoll::Poll
|
||||
# creation process. `raw` could be nil here.
|
||||
return [] if raw.blank?
|
||||
|
||||
# bail-out early if the post does not contain a poll
|
||||
return [] if !raw.include?("[/poll]")
|
||||
|
||||
# TODO: we should fix the callback mess so that the cooked version is available
|
||||
# in the validators instead of cooking twice
|
||||
raw = raw.sub(%r{\[quote.+/quote\]}m, "")
|
||||
|
||||
Reference in New Issue
Block a user