aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/src/Google/Protobuf/Internal/RepeatedField.php
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2018-06-07 18:16:44 -0700
committerGravatar GitHub <noreply@github.com>2018-06-07 18:16:44 -0700
commitce044817c7ba0aea27c3fd8e496635d94d20a755 (patch)
treef786537d923df55129a340480199859251ef2259 /php/src/Google/Protobuf/Internal/RepeatedField.php
parentd6353b489e16c5ff7dde4aa648f142a0d0b24ceb (diff)
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
Diffstat (limited to 'php/src/Google/Protobuf/Internal/RepeatedField.php')
-rw-r--r--php/src/Google/Protobuf/Internal/RepeatedField.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/php/src/Google/Protobuf/Internal/RepeatedField.php b/php/src/Google/Protobuf/Internal/RepeatedField.php
index 797b3b3a..e0ddef50 100644
--- a/php/src/Google/Protobuf/Internal/RepeatedField.php
+++ b/php/src/Google/Protobuf/Internal/RepeatedField.php
@@ -59,6 +59,10 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
* @ignore
*/
private $klass;
+ /**
+ * @ignore
+ */
+ private $legacy_klass;
/**
* Constructs an instance of RepeatedField.
@@ -71,7 +75,16 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
{
$this->container = [];
$this->type = $type;
- $this->klass = $klass;
+ if ($this->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();
+ }
}
/**
@@ -91,6 +104,14 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
}
/**
+ * @ignore
+ */
+ public function getLegacyClass()
+ {
+ return $this->legacy_klass;
+ }
+
+ /**
* Return the element at the given index.
*
* This will also be called for: $ele = $arr[0]