bjori/mongo-php-driver — pull request #12 by jmikola (2014-01-31 20:50:08+00:00)
Title: Fixed PHP-949: ensureIndex() creates wrong names

Technically, the only valid index orderings are numeric negative and positive 1 (int or float) or strings (for index plugins). The server happens to accept other orderings and will create names based on those orderings, which is arguably a bug.

Looking at BSONObj::woCompare() in the server source, ascending/descending is decided by whether or not the numeric ordering is zero. We'll utilize that logic to decide how to name the index (appending "-1" or "1" after the field name).

This also fixes an issue with to_index_string() altering its zval argument (covered in bug00949-003.phpt).