Skip to content

Commit 4579f73

Browse files
committed
Prevent PHP bug in json_decode(), if option JSON_BIGINT_AS_STRING is not implemented
closes #28
1 parent d1311af commit 4579f73

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8+
## [0.6.3] - 2016-04-26
9+
10+
### Fixed
11+
12+
- Prevent PHP bug in json_decode(), if option JSON_BIGINT_AS_STRING is not implemented, see [#28](https://github.com/Art4/json-api-client/issues/28)
13+
814
## [0.6.2] - 2016-04-15
915

1016
### Fixed
@@ -93,7 +99,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
9399
- Validator fits nearly 100% specification
94100
- Full test coverage
95101

96-
[Unreleased]: https://github.com/Art4/json-api-client/compare/0.6.2...HEAD
102+
[Unreleased]: https://github.com/Art4/json-api-client/compare/0.6.3...HEAD
103+
[0.6.3]: https://github.com/Art4/json-api-client/compare/0.6.2...0.6.3
97104
[0.6.2]: https://github.com/Art4/json-api-client/compare/0.6.1...0.6.2
98105
[0.6.1]: https://github.com/Art4/json-api-client/compare/0.6...0.6.1
99106
[0.6]: https://github.com/Art4/json-api-client/compare/0.5...0.6

src/Utils/Helper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ public static function decodeJson($json_string)
7272
JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded'
7373
);
7474

75-
$data = json_decode($json_string, false, 512, JSON_BIGINT_AS_STRING);
75+
// Can we use JSON_BIGINT_AS_STRING?
76+
$options = ( version_compare(PHP_VERSION, '5.4.0', '>=') and ! (defined('JSON_C_VERSION') and PHP_INT_SIZE > 4) ) ? JSON_BIGINT_AS_STRING : 0;
77+
$data = json_decode($json_string, false, 512, $options);
7678

7779
if ( json_last_error() !== JSON_ERROR_NONE )
7880
{

0 commit comments

Comments
 (0)