{"action":"created","issue":{"url":"https://api.github.com/repos/mongodb/mongo-php-library/issues/104","repository_url":"https://api.github.com/repos/mongodb/mongo-php-library","labels_url":"https://api.github.com/repos/mongodb/mongo-php-library/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/mongodb/mongo-php-library/issues/104/comments","events_url":"https://api.github.com/repos/mongodb/mongo-php-library/issues/104/events","html_url":"https://github.com/mongodb/mongo-php-library/issues/104","id":128207528,"number":104,"title":"Losing metadata when updating an object implementing Persistable","user":{"login":"gquemener","id":668604,"avatar_url":"https://avatars.githubusercontent.com/u/668604?v=3","gravatar_id":"","url":"https://api.github.com/users/gquemener","html_url":"https://github.com/gquemener","followers_url":"https://api.github.com/users/gquemener/followers","following_url":"https://api.github.com/users/gquemener/following{/other_user}","gists_url":"https://api.github.com/users/gquemener/gists{/gist_id}","starred_url":"https://api.github.com/users/gquemener/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gquemener/subscriptions","organizations_url":"https://api.github.com/users/gquemener/orgs","repos_url":"https://api.github.com/users/gquemener/repos","events_url":"https://api.github.com/users/gquemener/events{/privacy}","received_events_url":"https://api.github.com/users/gquemener/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-01-22T17:47:30Z","updated_at":"2016-02-22T20:44:08Z","closed_at":null,"body":"Hello,\r\n\r\nI'm having trouble updating one document that implements the Persistable interface.\r\nIt's unserialization metadata get lost every time I replace the document.\r\n\r\nHere's an exemple showing the problem:\r\n\r\n``` php\r\n<?php\r\n\r\nrequire 'vendor/autoload.php';\r\n\r\nclass A implements \\MongoDB\\BSON\\Persistable\r\n{\r\n    private $name;\r\n    public function __construct($name)\r\n    {\r\n        $this->name = $name;\r\n    }\r\n\r\n    public function setName($name)\r\n    {\r\n        $this->name = $name;\r\n    }\r\n\r\n    public function bsonSerialize()\r\n    {\r\n        return [\r\n            'name' => $this->name\r\n        ];\r\n    }\r\n\r\n    public function bsonUnserialize(array $data)\r\n    {\r\n        $this->name = $data['name'];\r\n    }\r\n}\r\n\r\n$instance = new A('foo');\r\n\r\n$manager = new \\MongoDB\\Driver\\Manager('mongodb://mongo:27017');\r\n$collection = new \\MongoDB\\Collection($manager, 'test', 'coll');\r\n$result = $collection->insertOne($instance);\r\n\r\n/**\r\n * > db.coll.find()\r\n * {\r\n *         \"_id\" : ObjectId(\"56a269e0046d5f0014645471\"),\r\n *         \"__pclass\" : BinData(128,\"QQ==\"),\r\n *         \"name\" : \"foo\"\r\n * }\r\n */\r\n\r\n$instance->setName('bar');\r\n$collection->replaceOne(['_id' => $result->getInsertedId()], $instance);\r\n\r\n/**\r\n * > db.coll.find()\r\n * { \"_id\" : ObjectId(\"56a26a97046d5f0039107a21\"), \"name\" : \"bar\" }\r\n */\r\n```\r\n\r\nWhat am I doing wrong here please?\r\n\r\nI'm running mongodb server v3.2.1.\r\n\r\nThanks in advance!"},"comment":{"url":"https://api.github.com/repos/mongodb/mongo-php-library/issues/comments/187374884","html_url":"https://github.com/mongodb/mongo-php-library/issues/104#issuecomment-187374884","issue_url":"https://api.github.com/repos/mongodb/mongo-php-library/issues/104","id":187374884,"user":{"login":"jmikola","id":244663,"avatar_url":"https://avatars.githubusercontent.com/u/244663?v=3","gravatar_id":"","url":"https://api.github.com/users/jmikola","html_url":"https://github.com/jmikola","followers_url":"https://api.github.com/users/jmikola/followers","following_url":"https://api.github.com/users/jmikola/following{/other_user}","gists_url":"https://api.github.com/users/jmikola/gists{/gist_id}","starred_url":"https://api.github.com/users/jmikola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmikola/subscriptions","organizations_url":"https://api.github.com/users/jmikola/orgs","repos_url":"https://api.github.com/users/jmikola/repos","events_url":"https://api.github.com/users/jmikola/events{/privacy}","received_events_url":"https://api.github.com/users/jmikola/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T20:44:08Z","updated_at":"2016-02-22T20:44:08Z","body":"FYI: [PHPC-550](https://jira.mongodb.org/browse/PHPC-550) has been merged and is slated for a 1.1.3 release this week."}}