Rammanojpotla has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405870 )

Change subject: Fix improper working of "round" operator
......................................................................

Fix improper working of "round" operator

Fixed improper behaviour of round operator when integer values
are given for rounding off instead of float values.

Bug: T8529
Change-Id: I57d0034e162646ea09e572bf54f7f04f91d90c78
---
M Expr.php
1 file changed, 6 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ParserFunctions 
refs/changes/70/405870/1

diff --git a/Expr.php b/Expr.php
index 18a2368..cf93853 100644
--- a/Expr.php
+++ b/Expr.php
@@ -508,7 +508,12 @@
                                }
                                $digits = (int)array_pop( $stack );
                                $value = array_pop( $stack );
-                               $stack[] = round( $value, $digits );
+                               if( ( is_numeric( $value ) && floor( $value ) 
!= $value || $digits < 0 ) ) {
+                                       $stack[] = round( $value, $digits );
+                               }
+                               else {
+                                       $stack[] = number_format( $value, 
$digits );
+                               }
                                break;
                        case EXPR_LESS:
                                if ( count( $stack ) < 2 ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/405870
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I57d0034e162646ea09e572bf54f7f04f91d90c78
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ParserFunctions
Gerrit-Branch: master
Gerrit-Owner: Rammanojpotla <rammanojpotla1...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to