mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-09-14 14:42:11 -04:00
* Fix “mark as read older than…” widening the active search Sibling searches of a `FreshRSS_BooleanSearch` are combined by OR, so `prepend()` added the maximum publication date used by the “mark as read → articles older than one day / one week” action as one more OR term instead of an extra restriction. With an active search and the stream sorted by publication date, that action therefore marked as read every article older than the cut-off (ignoring the search) plus every article matching the search at any date. `prepend()` now wraps the existing expression first, reusing the logic that `enforce()` already used for the same purpose. Co-Authored-By: Claude <noreply@anthropic.com> * Fix SQL space * Slight reduction of comments --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
34 lines
1.3 KiB
PHP
34 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
|
|
final class BooleanSearchTest extends \PHPUnit\Framework\TestCase {
|
|
|
|
/**
|
|
* `FreshRSS_BooleanSearch::prepend()` is used to restrict an existing search with an extra condition,
|
|
* such as the maximum publication date of the “mark as read → articles older than one day/week” action.
|
|
* @return list<array{string,string,list<string|int>}>
|
|
*/
|
|
public static function providePrependMaxPubdate(): array {
|
|
return [
|
|
['', '(e.date <= ?)', [1700000000]],
|
|
['intitle:sale', '(e.date <= ?) AND ((e.title LIKE ?))', [1700000000, '%sale%']],
|
|
['intitle:a OR intitle:b', '(e.date <= ?) AND ((e.title LIKE ?) OR (e.title LIKE ?))', [1700000000, '%a%', '%b%']],
|
|
];
|
|
}
|
|
|
|
/** @param list<string|int> $expectedValues */
|
|
#[DataProvider('providePrependMaxPubdate')]
|
|
public function test_prepend_restrictsTheSearchInsteadOfWideningIt(string $input, string $expectedSql, array $expectedValues): void {
|
|
$booleanSearch = new FreshRSS_BooleanSearch($input);
|
|
$maxPubdate = new FreshRSS_Search('');
|
|
$maxPubdate->setMaxPubdate(1700000000);
|
|
$booleanSearch->prepend($maxPubdate);
|
|
|
|
[$values, $sql] = FreshRSS_EntryDAO::sqlBooleanSearch('e.', $booleanSearch);
|
|
self::assertSame($expectedSql, trim($sql));
|
|
self::assertSame($expectedValues, $values);
|
|
}
|
|
}
|