php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73431 Loss of precision with xsd:integer and other huge integer types
Submitted: 2016-10-31 15:45 UTC Modified: 2021-01-15 15:03 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: perske at uni-muenster dot de Assigned:
Status: Open Package: SOAP related
PHP Version: 7.2.21 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: perske at uni-muenster dot de
New email:
PHP Version: OS:

 

 [2016-10-31 15:45 UTC] perske at uni-muenster dot de
Description:
------------
If a server returns a use integer like in
<Serial xsi:type="xsd:integer">8688597941889535165991696066</Serial>
The PHP script does not get the complete huge integer but a rounded float like
86885979418895E+27
This is inacceptable for most use cases.

To fix, modify ext/soap/php_encoding.c: Replace the line:
{{XSD_INTEGER, XSD_INTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
with the line
{{XSD_INTEGER, XSD_INTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_stringc, to_xml_string},

The same should be done with these lines:
{{XSD_NONPOSITIVEINTEGER, XSD_NONPOSITIVEINTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_POSITIVEINTEGER, XSD_POSITIVEINTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_NONNEGATIVEINTEGER, XSD_NONNEGATIVEINTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_NEGATIVEINTEGER, XSD_NEGATIVEINTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_INTEGER, XSD_INTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},


Test script:
---------------
n/a


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-31 16:51 UTC] perske at uni-muenster dot de
The change from to_xml_long to to_xml_string is not necessary,
but to_zval_long must be changed to to_zval_stringc (or to_zval_string).
 [2019-09-28 23:45 UTC] perske at uni-muenster dot de
-PHP Version: 7.0.12 +PHP Version: 7.2.21
 [2019-09-28 23:45 UTC] perske at uni-muenster dot de
Please check and implement the fix I have proposed. It hardly does break anything and it helps in many use cases of SOAP.
 [2020-07-05 00:03 UTC] perske at uni-muenster dot de
Please fix in the upcoming 8.0.
This bug is really annoying.
 [2020-08-13 12:37 UTC] perske at uni-muenster dot de
PLEASE add the proposed little fix to 8.0
With the switch to 8.0, this very minor backward incompatibility is really no problem.
 [2021-01-15 14:23 UTC] cmb@php.net
Would you mind to provide a pull request[1]?

[1] <https://github.com/php/php-src/pulls>
 [2021-01-15 15:03 UTC] perske at uni-muenster dot de
> Would you mind to provide a pull request?

I'm sorry but I do not know how to work with github.
But I think anybody who knows how to work with github can convert my proposed change into a pull request easily. Would anyone be so kind to do it?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 02 13:01:30 2025 UTC