mongodb/mongo-php-driver — pull request #423 by squarezhou (2013-04-27 09:55:54+00:00)
Title: merge array value if have the same key($set). Fixed a mistake when read oplog via php

First, mongodb support duplicate bson key in a collection document.

If you do an update like
`update({'uid':1}, {'$set':{'name':'foo'}, '$inc':{'count':1}})`
mongodb make an oplog document like
`{ "ts" : { "t" : 1367057935000, "i" : 2 }, "op" : "u", "ns" : "test.test", "o2" : { "_id" : ObjectId("517ba5f2f57fd86b0599a532") }, "o" : { "$set" : { "name" : 'foo' }, "$set" : { "count" : 2 } } }`
If your output is
`"o" : { "$set" : { "count" : 2 }, "$set" : { "count" : 2 } }`
i think its a bug in linux bash, the origin data stored in mongodb is the previous.

So, there are two '$set' key name in 'o' document, mongodb can parse this correctly but PHP(and other language) can't. PHP will convert the bson document to array, and PHP could't have the same key in an array.

The addition code will merge array value if the key already exists in result HashTable.

Thank you.