Page MenuHomePhabricator

Edit_delta doesn't triple-compare to numbers
Closed, ResolvedPublic


Title is quite self-explanatory. Consider the variable edit_delta, and take 2 edits, one with edit_delta > 0 and one with edit_delta < 0. On the first one, if you do edit_delta === ## will return true, while on the second one it won't. By examining vars from JS console, however, a negative edit_delta appears as a number, as expected. This isn't that big problem, since usually edit_delta is used in a comparison (< or >) where the value is casted to number and works fine, but we'd better fix it anyway.

ADD: Oh, the funny part! edit_delta === '-##' returns false as well.

Event Timeline

Daimona created this task.Mar 25 2018, 3:42 PM
Restricted Application added subscribers: Scoopfinder, Aklapper. · View Herald TranscriptMar 25 2018, 3:42 PM
Daimona updated the task description. (Show Details)Mar 25 2018, 3:44 PM

First bit of investigation. I found the reason: they fail to triple-equal because a negative edit_delta is float, while -1 is integer. I still need to determine why this happens and if there's a way to easily fix it.

Daimona claimed this task.Mar 25 2018, 4:48 PM

Patch coming tonight.

Change 421796 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Use integers when calculating edit_delta

The patch will fix it anyway, but I also noticed that edit_delta NEVER triple-compares to an integer, since it's always a float.

Change 421796 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Use integers when calculating edit_delta

Daimona renamed this task from A negative edit_delta is NOT a number to Edit_delta doesn't triple-compare to numbers.Mar 26 2018, 12:04 PM
Daimona closed this task as Resolved.
Daimona removed a project: Patch-For-Review.