Use integers when calculating edit_delta

Since it'll always be a subtraction of integer numbers. Otherwise, if
calculated as float, values won't triple-compare.

Bug: T190652
Change-Id: Ia58a4e3429a012a94a43ffadb190154fcdb9bcaa
This commit is contained in:
Daimona Eaytoy 2018-03-25 19:19:10 +02:00
parent e18cd9b92d
commit 1de8740df7
2 changed files with 4 additions and 4 deletions

View file

@ -364,9 +364,9 @@ class AFComputedVariable {
$s = $vars->getVar( $parameters['length-var'] )->toString();
$result = strlen( $s );
break;
case 'subtract':
$v1 = $vars->getVar( $parameters['val1-var'] )->toFloat();
$v2 = $vars->getVar( $parameters['val2-var'] )->toFloat();
case 'subtract-int':
$v1 = $vars->getVar( $parameters['val1-var'] )->toInt();
$v2 = $vars->getVar( $parameters['val2-var'] )->toInt();
$result = $v1 - $v2;
break;
case 'revision-text-by-id':

View file

@ -2352,7 +2352,7 @@ class AbuseFilter {
[ 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_pst' ] );
$vars->setLazyLoadVar( 'new_size', 'length', [ 'length-var' => 'new_wikitext' ] );
$vars->setLazyLoadVar( 'old_size', 'length', [ 'length-var' => 'old_wikitext' ] );
$vars->setLazyLoadVar( 'edit_delta', 'subtract',
$vars->setLazyLoadVar( 'edit_delta', 'subtract-int',
[ 'val1-var' => 'new_size', 'val2-var' => 'old_size' ] );
// Some more specific/useful details about the changes.