zendframework/zf2 — pull request #6525 by hver (2014-08-05 10:43:21+00:00)
Title: AbstractAdapter::getItem() should return null, if the item cannot be retrieved

The AbstractAdapter::getItem() is specified to return *null*, if the item cannot be retrieved. Also the *$success* variable passed by reference should be set to *false* in this case.

In our setup we've encountered errors, because it was not the case. We are using Redis as cache, and have configured the ExceptionHandler Plugin to not throw exceptions ('throw_exceptions' => false), because if the cache fails, it is not breaking the application. But in this case, if the Redis server is unavailable, the getItem() function, return *false* instead of *null*, also the *$success* variable is set to *null* instead of *false*. This is not the expected behavior, and our app was broken, because we checked explicitly, if the return value is strictly not null ($value !== null)

The problem is not only in Redis, but in the AbstractAdapter generally. If there is an exception in getItem(), and this exception is ignored (which is rather ok, for the cache), the $success var is not set and the result equals to null.

As a proof, i have made a unit test for the Redis class. It would be better, to make a general AbstractAdapter unit test, i could make if you give me some ideas how it can be done :)