Treat all time values on Special:Watchlist as floats
authorMatěj Suchánek <matejsuchanek97@gmail.com>
Sun, 29 Jul 2018 09:54:45 +0000 (11:54 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 30 Jul 2018 12:05:37 +0000 (12:05 +0000)
PHP division may return float or int, depending on the operands. [1]
Make sure all numbers are of the same type (floats), because
XmlSelect compares values with ===.

[1] http://php.net/manual/en/language.operators.arithmetic.php

Bug: T199566
Change-Id: I37df6fd425f47d9a4562d83e04fcb50c3b97e0da

includes/specials/SpecialWatchlist.php

index 41a059f..5b48f4e 100644 (file)
@@ -777,7 +777,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                ] ) );
                asort( $hours );
 
-               $select = new XmlSelect( 'days', 'days', $selectedHours / 24 );
+               $select = new XmlSelect( 'days', 'days', (float)( $selectedHours / 24 ) );
 
                foreach ( $hours as $value ) {
                        if ( $value < 24 ) {
@@ -785,7 +785,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        } else {
                                $name = $this->msg( 'days' )->numParams( $value / 24 )->text();
                        }
-                       $select->addOption( $name, $value / 24 );
+                       $select->addOption( $name, (float)( $value / 24 ) );
                }
 
                return $select->getHTML() . "\n<br />\n";