Pastakhov has submitted this change and it was merged.

Change subject: Fix string to number conversion in Compiler (v 5.7.2) Runtime 10
......................................................................


Fix string to number conversion in Compiler (v 5.7.2) Runtime 10

There were different values in pure PHP and PhpTags. Now it the same.

Problem depends of conversion string by operator (int):
Example: 
echo 'int ' . (int)420000000000000000000,
 "\nint string " . (int)"420000000000000000000",
 "\nstring+0 " . ("420000000000000000000" + 0);

Output for 5.3.22 - 5.4.45, hhvm-3.6.1 - 3.12.0
int 0
int string 9223372036854775807
string+0 4.2E+20

Output for 5.5.0 - 7.0.3
int -4275113695319687168
int string 9223372036854775807
string+0 4.2E+20

Now it doing through operation string + 0

Change-Id: I1ec745fb100aa680ad6a05d5a669e7b7b2010586
---
M PhpTags.php
M includes/Compiler.php
2 files changed, 4 insertions(+), 9 deletions(-)

Approvals:
  Pastakhov: Verified; Looks good to me, approved



diff --git a/PhpTags.php b/PhpTags.php
index 427bf0e..07d18ae 100644
--- a/PhpTags.php
+++ b/PhpTags.php
@@ -17,11 +17,11 @@
 
 const PHPTAGS_MAJOR_VERSION = 5;
 const PHPTAGS_MINOR_VERSION = 7;
-const PHPTAGS_RELEASE_VERSION = 1;
+const PHPTAGS_RELEASE_VERSION = 2;
 define( 'PHPTAGS_VERSION', PHPTAGS_MAJOR_VERSION . '.' . PHPTAGS_MINOR_VERSION 
. '.' . PHPTAGS_RELEASE_VERSION );
 
 const PHPTAGS_HOOK_RELEASE = 8;
-const PHPTAGS_RUNTIME_RELEASE = 9;
+const PHPTAGS_RUNTIME_RELEASE = 10;
 const PHPTAGS_JSONLOADER_RELEASE = 3;
 
 // Register this extension on Special:Version
diff --git a/includes/Compiler.php b/includes/Compiler.php
index 0b8828c..a9fb168 100644
--- a/includes/Compiler.php
+++ b/includes/Compiler.php
@@ -453,17 +453,12 @@
                                                $tmp = intval( $text, 8 );
                                        }
                                } else {
-                                       $tmp = (int)$text;
+                                       $tmp = $text + 0;
                                }
                                $result = array( Runtime::B_COMMAND=>null, 
Runtime::B_RESULT=>$tmp, Runtime::B_TOKEN_LINE=>$this->tokenLine, 
Runtime::B_DEBUG=>$text );
                                break;
                        case T_DNUMBER:
-                               $epos = stripos($text, 'e');
-                               if ( $epos === false ) {
-                                       $tmp = (float)$text;
-                               } else {
-                                       $tmp = (float)( substr($text, 0, $epos) 
* pow(10, substr($text, $epos+1)) );
-                               }
+                               $tmp = $text + 0;
                                $result = array( Runtime::B_COMMAND=>null, 
Runtime::B_RESULT=>$tmp, Runtime::B_TOKEN_LINE=>$this->tokenLine, 
Runtime::B_DEBUG=>$text );
                                break;
                        case T_CONSTANT_ENCAPSED_STRING:

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1ec745fb100aa680ad6a05d5a669e7b7b2010586
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/PhpTags
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <pastak...@yandex.ru>
Gerrit-Reviewer: Pastakhov <pastak...@yandex.ru>

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

Reply via email to