Skip to content

Commit

Permalink
Add basic Logging when using fallback guid - Update tests to account …
Browse files Browse the repository at this point in the history
…for additional logging

Signed-off-by: Accalia <Accalia@Elementia.me>
  • Loading branch information
AccaliaDeElementia committed May 24, 2022
1 parent 00289ce commit f4ed345
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/Fetcher/FeedFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,15 @@ protected function buildItem(ItemInterface $parsedItem, ?string $body = null, bo
$item = new Item();
$item->setUnread(true);
$itemLink = $parsedItem->getLink();
$itemTitle = $parsedItem->getTitle();
$item->setUrl($itemLink);
$publicId = $parsedItem->getPublicId();
if ($publicId == null) {
// Fallback on using the URL as the guid for the feed item if no guid provided by feed
$this->logger->debug(
"Feed item {title} with link {link} did not expose a guid, falling back to using link as guid",
[
'title' => $parsedItem->getTitle(),
'title' => $itemTitle,
'link' => $itemLink
]
);
Expand All @@ -268,8 +269,8 @@ protected function buildItem(ItemInterface $parsedItem, ?string $body = null, bo
$item->setRtl($RTL);

// unescape content because angularjs helps against XSS
if ($parsedItem->getTitle() !== null) {
$item->setTitle($this->decodeTwice($parsedItem->getTitle()));
if ($itemTitle !== null) {
$item->setTitle($this->decodeTwice($itemTitle));
}
$author = $parsedItem->getAuthor();
if ($author !== null && $author->getName() !== null) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Fetcher/FeedFetcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ private function createItem($enclosureType = null)
$this->item_mock->expects($this->exactly(1))
->method('getLink')
->will($this->returnValue($this->permalink));
$this->item_mock->expects($this->exactly(2))
$this->item_mock->expects($this->exactly(1))
->method('getTitle')
->will($this->returnValue($this->title));
$this->item_mock->expects($this->exactly(1))
Expand Down

0 comments on commit f4ed345

Please sign in to comment.