From ce044817c7ba0aea27c3fd8e496635d94d20a755 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Thu, 7 Jun 2018 18:16:44 -0700 Subject: Use legacy name in php runtime (#4741) * Use legacy name in php runtime Old generated code cannot work with new runtime, because the new runtime assumes new class name for nested message. For details see #4738. * Remove unused method --- php/src/Google/Protobuf/Internal/MapField.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'php/src/Google/Protobuf/Internal/MapField.php') diff --git a/php/src/Google/Protobuf/Internal/MapField.php b/php/src/Google/Protobuf/Internal/MapField.php index 38736dad..f7d7b710 100644 --- a/php/src/Google/Protobuf/Internal/MapField.php +++ b/php/src/Google/Protobuf/Internal/MapField.php @@ -58,7 +58,11 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable /** * @ignore */ - private $value_klass; + private $klass; + /** + * @ignore + */ + private $legacy_klass; /** * Constructs an instance of MapField. @@ -75,6 +79,17 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable $this->key_type = $key_type; $this->value_type = $value_type; $this->klass = $klass; + + if ($this->value_type == GPBType::MESSAGE) { + $pool = DescriptorPool::getGeneratedPool(); + $desc = $pool->getDescriptorByClassName($klass); + if ($desc == NULL) { + new $klass; // No msg class instance has been created before. + $desc = $pool->getDescriptorByClassName($klass); + } + $this->klass = $desc->getClass(); + $this->legacy_klass = $desc->getLegacyClass(); + } } /** @@ -101,6 +116,14 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable return $this->klass; } + /** + * @ignore + */ + public function getLegacyValueClass() + { + return $this->legacy_klass; + } + /** * Return the element at the given key. * -- cgit v1.2.3