Problem/Motivation
Currently both deleteInHash() implementations Redis_Path_PhpRedis::deleteInHash() as well as Redis_Path_Predis::deleteInHash() use an invalid condition to figure out if something to delete was found:
if ($index = array_search($hvalue, $existing)) { won't work if the found key is 0.
This leads to artefacts in the path handling e.g. a deleted alias still will find the source, thus the cache will be pre-set and it looks like the alias is still available.
Proposed resolution
Use if (($index = array_search($hvalue, $existing)) !== FALSE) {
Remaining tasks
Reviews needed.
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| redis-fix-deleteInHash.patch | 1.16 KB | das-peter |
Comments
Comment #2
pounardNice catch, thanks for reporting.
Comment #4
pounardThanks for this, I also added basic unit tests for path replacement, and fixed in both Predis and PhpRedis implementations, along with few cleanups.
Comment #5
das-peter commented@pounard Awesome, thank you very much!
You shouldn't have attributed the authorship for the TestCases to me - now people will expect tests from me :P
Comment #6
pounardSo you never write unit tests ? Now I know your secret.
I just did credit both of us because I wrote the tests, but you did the hard part that was finding the issue and providing a working patch, so really thank you very much for that!