diff --git a/php/src/Google/Protobuf/Internal/DescriptorPool.php b/php/src/Google/Protobuf/Internal/DescriptorPool.php index 621e2e6b17..4f01180d78 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorPool.php +++ b/php/src/Google/Protobuf/Internal/DescriptorPool.php @@ -20,6 +20,7 @@ class DescriptorPool private static $pool; // Map from message names to sub-maps, which are maps from field numbers to // field descriptors. + private $unique_descs = []; private $class_to_desc = []; private $class_to_enum_desc = []; private $proto_to_class = []; @@ -71,6 +72,8 @@ class DescriptorPool { $this->proto_to_class[$descriptor->getFullName()] = $descriptor->getClass(); + $this->unique_descs[$descriptor->getFullName()] = + $descriptor; $this->class_to_desc[$descriptor->getClass()] = $descriptor; $this->class_to_desc[$descriptor->getLegacyClass()] = $descriptor; $this->class_to_desc[$descriptor->getPreviouslyUnreservedClass()] = $descriptor; @@ -163,7 +166,7 @@ class DescriptorPool public function finish() { - foreach ($this->class_to_desc as $klass => $desc) { + foreach ($this->unique_descs as $klass => $desc) { $this->crossLink($desc); } unset($desc);