zendframework / zend-cache

BSD 3-Clause "New" or "Revised" License
69 stars 53 forks source link

Handle item removal consistent with PSR-16 from SimpleCacheDecorator #163

Closed weierophinney closed 6 years ago

weierophinney commented 6 years ago

PSR-16 states that delete() and deleteMultiple() should return false in the case of an error, not throw an exception. This patch modifies the catch statements of each to return false accordingly.

Additionally, it modifies the return $this->storage->removeItem($key) to read return (bool) $this->storage->removeItem($key);. When using the ExceptionHandler plugin, it's possible for a void or null return value due to never receiving a result from the adapter for the operation; by casting to boolean, we ensure it properly indicates failure per the PSR-16 specification.

This patch also documents pitfalls with delete() and deleteMultiple() with regards to plugins changing the throw behavior and/or altering the result.

Finally, this patch documents which adapters require the Serializer plugin when used with PSR-16.

Alternative to #160 Fixes #158

weierophinney commented 6 years ago

Test failure was due to a timeout. I've tried two different ways to increase it, but none of them are being honored, so at this point, we just have to restart jobs as necessary. Since only one environment timed out and all others passed, this is ready.

thomasvargiu commented 6 years ago

@weierophinney can we ignore composer scripts and run phpunit directly?