mattparlane/mongo-php-driver — comment on commit 002e069514fa7594ce0a03961a129832446e2fb4
File: collection.c line 718
By derickr:

I think this bit is the problem, because it prevents the "sparse" flag from being added to the ensureIndex command. The other options are "pseudo" options that are used internally. Now you remove (zend_hash_del) the sparse flag before it's being sent to the server.