discourse/lib/validators
Sam a7628c1d74 FIX: use ordered_posts for last post check, not the posts relation
The `posts` relation on `Topic` is not ordered. Using `Topic.posts.first`
is basically the same as asking for a random post, it will depend on DB
order. This breaks on Topic merge and split for example.

Additionally, a huge problem with that is that it forces active record down
a slow path. `Topic.posts.first` is extremely slow on giant topics, since
it has no default ordering it appears AR materializes the entire set prior
to doing `first`.

This commit also illustrates the importance of testing, initially I only
fixed the second instance of the problem in `post_validator.rb` but testing
revealed that the problem was repeated at the top of the file.

Longer term we should consider a larger change of default ordering the posts
relations so people do not fall down this trap anymore.
2019-01-18 13:18:40 +11:00
..
allow_user_locale_enabled_validator.rb DEV: Enable `Style/SingleLineMethods` and `Style/Semicolon` in Rubocop (#6717) 2018-12-04 11:48:13 +08:00
allowed_ip_address_validator.rb
alternative_reply_by_email_addresses_validator.rb
censored_words_validator.rb Make rubocop happy again. 2018-06-07 13:28:18 +08:00
email_setting_validator.rb
email_validator.rb SECURITY: email domain whitelist could be bypassed 2018-01-17 21:45:32 +01:00
enable_local_logins_via_email_validator.rb FEATURE: login by a link from email 2018-02-13 16:14:39 +08:00
enable_private_email_messages_validator.rb
enable_sso_validator.rb
integer_setting_validator.rb
ip_address_format_validator.rb
max_emojis_validator.rb fix the build 2018-10-22 15:09:25 +05:30
max_username_length_validator.rb Remove unecessary code. 2018-10-02 15:24:12 +08:00
min_username_length_validator.rb Remove unecessary code. 2018-10-02 15:24:12 +08:00
password_validator.rb
pop3_polling_enabled_setting_validator.rb Make rubocop happy again. 2018-06-07 13:28:18 +08:00
post_validator.rb FIX: use ordered_posts for last post check, not the posts relation 2019-01-18 13:18:40 +11:00
quality_title_validator.rb
regex_presence_validator.rb FIX: validate presence of 'top menu' setting 2018-01-17 01:43:53 +05:30
regex_setting_validation.rb
regex_setting_validator.rb
reply_by_email_address_validator.rb FIX: don't allow spaces in 'reply_by_email_address' site setting 2018-04-17 17:08:12 +02:00
reply_by_email_enabled_validator.rb
sso_overrides_email_validator.rb
string_setting_validator.rb
stripped_length_validator.rb
topic_title_length_validator.rb Make rubocop happy again. 2018-06-07 13:28:18 +08:00
unique_among_validator.rb
upload_url_validator.rb FIX: store the topic links using the cooked upload url 2018-08-14 12:23:32 +02:00
upload_validator.rb FEATURE: Upload Site Settings. (#6573) 2018-11-14 15:03:02 +08:00
url_validator.rb FIX: store the topic links using the cooked upload url 2018-08-14 12:23:32 +02:00
user_full_name_validator.rb
username_setting_validator.rb