8000 bug #59318 [Finder] Fix using `==` as default operator in `DateCompar… · symfony/symfony@1236323 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1236323

Browse files
committed
bug #59318 [Finder] Fix using == as default operator in DateComparator (MatTheCat)
This PR was merged into the 6.4 branch. Discussion ---------- [Finder] Fix using `==` as default operator in `DateComparator` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #59314 | License | MIT `$matches` can only contain `null` when passing the [`PREG_UNMATCHED_AS_NULL`](https://www.php.net/manual/en/pcre.constants.php#constant.preg-unmatched-as-null) flag. Since the culprit code line predates PHP 7.2 I made it check for an empty string rather than `null`, as `@GlucNAc` suggested. Commits ------- a247d58 [Finder] Fix using `==` as default operator in `DateComparator`
2 parents a4f0258 + a247d58 commit 1236323

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/Finder/Comparator/DateComparator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(string $test)
3636
throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
3737
}
3838

39-
$operator = $matches[1] ?? '==';
39+
$operator = $matches[1] ?: '==';
4040
if ('since' === $operator || 'after' === $operator) {
4141
$operator = '>';
4242
}

src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public static function getTestData()
5959
['after 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
6060
['since 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
6161
['!= 2005-10-10', [strtotime('2005-10-11')], [strtotime('2005-10-10')]],
62+
['2005-10-10', [strtotime('2005-10-10')], [strtotime('2005-10-11')]],
6263
];
6364
}
6465
}

0 commit comments

Comments
 (0)
0