From 9b22a3cdaffe91eeb5cae517f293d1a03c2f9b71 Mon Sep 17 00:00:00 2001 From: Bez Hermoso Date: Mon, 27 Oct 2014 09:58:24 -0700 Subject: [PATCH] Supress potential E_NOTICES about integer overflows due to unusually high/low scores. --- src/Elasticsearch/Serializers/SmartSerializer.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Elasticsearch/Serializers/SmartSerializer.php b/src/Elasticsearch/Serializers/SmartSerializer.php index f4054e23e..3970c09f9 100644 --- a/src/Elasticsearch/Serializers/SmartSerializer.php +++ b/src/Elasticsearch/Serializers/SmartSerializer.php @@ -57,7 +57,14 @@ public function deserialize($data, $headers) { if (isset($headers['content_type']) === true) { if (strpos($headers['content_type'], 'json') !== false) { - return json_decode($data, true); + + // Unusually high/low scores may cause integer overflows. Supress E_NOTICEs momentarily. + $e = error_reporting(); + error_reporting($e ^ E_NOTICE); + $decoded = json_decode($data, true); + error_reporting($e); + + return $decoded; } else { //Not json, return as string return $data;