Skip to content

Commit

Permalink
Merge pull request #132 from Toflar/fix-cache-key
Browse files Browse the repository at this point in the history
Fix result cache key in CompilingMatcher
  • Loading branch information
Seldaek authored Mar 16, 2022
2 parents f79c90a + eca295a commit f7ebdcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CompilingMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function clear()
*/
public static function match(ConstraintInterface $constraint, $operator, $version)
{
$resultCacheKey = $operator.$constraint.$version;
$resultCacheKey = $operator.$constraint.';'.$version;

if (isset(self::$resultCache[$resultCacheKey])) {
return self::$resultCache[$resultCacheKey];
Expand Down
6 changes: 6 additions & 0 deletions tests/CompilingMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ public function testMatch()
{
$this->assertTrue(CompilingMatcher::match(new Constraint('>=', '1'), Constraint::OP_EQ, '2'));
}

public function testCacheKey()
{
$this->assertFalse(CompilingMatcher::match(new Constraint('>=', '2.11'), Constraint::OP_EQ, '1.0'));
$this->assertTrue(CompilingMatcher::match(new Constraint('>=', '2.1'), Constraint::OP_EQ, '11.0'));
}
}

0 comments on commit f7ebdcb

Please sign in to comment.