Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Add logic to set the node's link from the <guid> element when isPermaLink="true" and no link is present. (#12)
- Do no longer default to 1800-01-01 as date for fetching feeds (#15)

### Fixed
- Fix: Analysis of relative links for the Atom feed (#13)
- Analysis of relative links for the Atom feed (#10)
3 changes: 0 additions & 3 deletions src/FeedIo/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ public function addParser(ParserAbstract $parser): Reader
public function read(string $url, FeedInterface $feed, DateTime $modifiedSince = null): Result
{
$this->logger->debug("start reading {$url}");
if (is_null($modifiedSince)) {
$modifiedSince = new DateTime('1800-01-01');
}

try {
$this->logger->info("hitting {$url}");
Expand Down
11 changes: 9 additions & 2 deletions src/FeedIo/Reader/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Result
public function __construct(
protected Document $document,
protected FeedInterface $feed,
protected DateTime $modifiedSince,
protected ?DateTime $modifiedSince = null,
protected ResponseInterface $response,
protected string $url
) {
Expand All @@ -56,8 +56,15 @@ public function getFeed(): FeedInterface

public function getItemsSince(DateTime $since = null): iterable
{
$startDate = $since ?? $this->modifiedSince;

// return all items if no start date is given
if ($startDate === null) {
return $this->feed;
}

$filter = new Chain();
$filter->add(new Since($since ?? $this->modifiedSince));
$filter->add(new Since($startDate));

return $filter->filter($this->getFeed());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/FeedIo/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function testReadWithoutModifiedSince()
$feed = new Feed();
$this->object->addParser($this->getParser());
$result = $this->object->read('fakeurl', $feed);
$this->assertEquals(new \DateTime('1800-01-01'), $result->getModifiedSince());
$this->assertEquals(null, $result->getModifiedSince());
}

public function testReadException()
Expand Down