mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 05:53:52 +08:00
FIX: Limit post read time to the max integer value (#12126)
Some users somehow manage to keep a topic open for a very long time that it causes the post read time to exceed the max integer value (2^31 - 1) which causes errors when we try to update the read time in the database to values above the integer limit. This PR will cap posts read time at 2^31 - 1 to prevent these errors.
This commit is contained in:
@ -3057,6 +3057,29 @@ RSpec.describe TopicsController do
|
||||
expect(post_timing.user).to eq(user)
|
||||
expect(post_timing.msecs).to eq(2)
|
||||
end
|
||||
|
||||
it 'caps post read time at the max integer value (2^31 - 1)' do
|
||||
PostTiming.create!(
|
||||
topic_id: post_1.topic.id,
|
||||
post_number: post_1.post_number,
|
||||
user_id: user.id,
|
||||
msecs: 2**31 - 10
|
||||
)
|
||||
sign_in(user)
|
||||
|
||||
post "/topics/timings.json", params: {
|
||||
topic_id: topic.id,
|
||||
topic_time: 5,
|
||||
timings: { post_1.post_number => 100 }
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
post_timing = PostTiming.first
|
||||
|
||||
expect(post_timing.topic).to eq(topic)
|
||||
expect(post_timing.user).to eq(user)
|
||||
expect(post_timing.msecs).to eq(2**31 - 1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#timer' do
|
||||
|
Reference in New Issue
Block a user