aboutsummaryrefslogtreecommitdiff
path: root/php/src/Google/Protobuf/Internal/Message.php
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2018-09-22 18:57:43 -0700
committerGitHub <noreply@github.com>2018-09-22 18:57:43 -0700
commit9bda1f19bf12aaf62a3bf65e8f72c72f82ff7af7 (patch)
tree2b96da21c057c4c862995554022a54881f492dc6 /php/src/Google/Protobuf/Internal/Message.php
parent47d33e752e5256bec315e5867b940ca33d66e8a2 (diff)
downloadprotobuf-9bda1f19bf12aaf62a3bf65e8f72c72f82ff7af7.tar.gz
protobuf-9bda1f19bf12aaf62a3bf65e8f72c72f82ff7af7.tar.bz2
protobuf-9bda1f19bf12aaf62a3bf65e8f72c72f82ff7af7.zip
Adopt upb change for timestamp and duration json to php (#5106)
* Adopt upb change for timestamp and duration json to php * Remove unused code * Re-sync upb * Fix php implementation timestamp json parsing * Fix strptime use local timezone on mac. * Remove succeeding tests * Resync * Add tests for values * Fix php tests * Fix encoder handlers change default value Previously, oneofsubmsg_handler and submsg_handler change zval's default value directly. The fix use REPLACE_ZVAL_VALUE which create a copy of parsed value and assign it to zval.
Diffstat (limited to 'php/src/Google/Protobuf/Internal/Message.php')
-rw-r--r--php/src/Google/Protobuf/Internal/Message.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php
index 8ff141ca..147aaab8 100644
--- a/php/src/Google/Protobuf/Internal/Message.php
+++ b/php/src/Google/Protobuf/Internal/Message.php
@@ -1157,9 +1157,17 @@ class Message
public function parseFromJsonStream($input)
{
$array = json_decode($input->getData(), true, 512, JSON_BIGINT_AS_STRING);
+ if ($this instanceof \Google\Protobuf\ListValue) {
+ $array = ["values"=>$array];
+ }
if (is_null($array)) {
- throw new GPBDecodeException(
- "Cannot decode json string.");
+ if ($this instanceof \Google\Protobuf\Value) {
+ $this->setNullValue(\Google\Protobuf\NullValue::NULL_VALUE);
+ return;
+ } else {
+ throw new GPBDecodeException(
+ "Cannot decode json string: " . $input->getData());
+ }
}
try {
$this->mergeFromJsonArray($array);