Steps:
- Create a post with a 20-character body and edit it once, so it has an edit history and the pencil shows.
- Raise
min_post_length(ormin_first_post_lengthfor a first post) above the post’s length. - As staff, open the edit history and hide revision 2.
Expected: non-staff users no longer see the pencil (public_version back to 1).
Actual: the revision is hidden, but public_version stays at 2, so non-staff still see the pencil and an edit history with nothing visible in it. The request returns 200.
Cause: in PostsController#hide_revision, post_revision.hide! uses update_column, but the version change is saved with a plain post.save, which runs PostValidator and isn’t checked:
post.public_version -= 1
post.save
Any post that fails validation today doesn’t save. That includes posts that predate a settings change, posts created with skip_validations (imports), posts containing a watched word added later, and posts by TL0 users over the newuser_max_* limits. show_revision probably has the same issue in the other direction.
Suggested fix: post.update_columns(public_version: post.public_version - 1), or post.save(validate: false), matching hide!.