Copilot commented on code in PR #3795:
URL: https://github.com/apache/thrift/pull/3795#discussion_r3943486383


##########
lib/php/test/Integration/Lib/Serializer/BinarySerializerTest.php:
##########
@@ -43,4 +43,20 @@ public function testBinarySerializer()
         $deserialized = TBinarySerializer::deserialize($serialized, 
'\\Basic\\ThriftTest\\Xtruct');
         $this->assertEquals($struct, $deserialized);
     }
+
+    public function testBinarySerializerAfterPhpUnserialize(): void
+    {
+        $struct = new \Basic\ThriftTest\Xtruct(['string_thing' => 'abc']);
+
+        /** @var \Basic\ThriftTest\Xtruct $restored */
+        $restored = unserialize(serialize($struct));
+        $this->assertEquals($struct, $restored);
+
+        // Guard THRIFT-3874: generated PHP classes must keep their type
+        // metadata usable after PHP wakeup/unserialize.
+        $serialized = TBinarySerializer::serialize($restored, 
'\\Basic\\ThriftTest\\Xtruct');
+        $deserialized = TBinarySerializer::deserialize($serialized, 
'\\Basic\\ThriftTest\\Xtruct');

Review Comment:
   The PHP serialize()/unserialize() round-trip should be explicit and 
type-safe (unserialize() can return false and should restrict allowed_classes). 
Also, TBinarySerializer::serialize() only accepts the object argument, so the 
extra class-name parameter should be removed (it appears twice in this file).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to