zendframework/zf2 — pull request #2031 by jmikola (2012-07-27 21:07:47+00:00)
Title: Added MongoDB session save handler

I based the test on the existing DB session save handler, which appears to be a functional test even though it is labeled as a unit test.

This was the first time I came across an options objects, so I added the database name, collection name, and save options in there instead of constructor arguments (as was done in the MongoDB log writer). The Mongo connection itself is still a constructor argument.

I also removed the save path property on the handler class, as that wasn't used at all (in any of the existing handlers). I have reservations about the `ini_get()` call in `open()`, and feel all of the handler classes would do well to inject that option, but I'd like to solicit feedback on that before deviating from the existing convention.

Also, it's not clear to me where session ID's are generated. I decided to use the session ID as Mongo's `_id` field, which implicitly has a unique index. I imagine the DB table might only have a unique index on the ID and session name combination. If that's the case, I may want to change that and let Mongo generate it's own ObjectId for `_id` and store the session ID in its own document field (so the user can create their own compound, unique index). The common in `MongoDB::write()` (and the test) explains my concern.