nicktacular / php-mongo-session

A PHP session handler with a Mongo DB backend.
MIT License
18 stars 6 forks source link

Create a php mock for mimicking how php interacts with a session handler. #16

Closed nicktacular closed 9 years ago

nicktacular commented 9 years ago

The description says it all. Spinoff from #14.

nicktacular commented 9 years ago

Last night I wrote a session emulator in PHP. Going to test it out and add in some tests for this class. One thing I realized is that sessions could be far more flexible if we abandoned using session_ functions and $_SESSION variable in PHP. Consider a session handler that gave you the ability to do a non-blocking read with $handler->get('key') or $handler->write('key', 'data') with the ability to not block, similar to what LOCK_NB does in PHPs flock function. </rant>

Anyhow, I'll post the emulator sometime next week most likely.

FYI @rocksfrow @mikeytag

nicktacular commented 9 years ago

Almost done with this FYI. Should be another couple of days to finish.

nicktacular commented 9 years ago

Just a quick update. I've finished the mocking lib and have completed some tests for this lib. @rocksfrow you'll be interested to know that I've tracked down a small bug relating to locks being left in the lock collection. If there's ever a session id regeneration that occurs, that does not clean up after it self and incorrectly assumes the presence of a the new session lock without deleting the old one. this will definitely cause locks to remain. So any instance of remaining locks isn't as bad as it seems (i.e. locked out users) it most likely means session id regeneration.

I continue down the testing path and hope to have a new branch up soon.

What do you guys think about introducing a new set of methods that are smarter regarding session locks?

nicktacular commented 9 years ago

I've committed to a branch called testing. This is my first step towards working on improvements for this class. Let's discuss in here with references to the code. Here are my @todos on this:

  1. Clean up write options #18
  2. Identify more test cases and implement as functional tests
  3. Figure out if TravisCI can run with a MongoDB dependency for functional tests, or, if not, who else?
  4. Write some benchmarks to get a baseline for this current implementation in testing branch which is effectively no different from master from a performance perspective.
  5. Discuss how to implement an alternative fine-grained session data locking, referencing @mikeytag's idea.

These are all up for grabs, if you're interested. Would someone like to take on # 4?