Skip to content

Commit 09cabdb

Browse files
authored
Merge pull request #236 from os2display/feature/3941-bug-media-url-null
Notified Feed Type bug when media url is null
2 parents f7e58a1 + 3c0ea5e commit 09cabdb

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
- [#236](https://github.com/os2display/display-api-service/pull/236)
8+
- Fixed bug where no media url made Notified feed crash.
79
- [#231](https://github.com/os2display/display-api-service/pull/231)
810
- Adds new feed source: Eventdatabasen v2.
911
- [#233](https://github.com/os2display/display-api-service/pull/233)

src/Feed/NotifiedFeedType.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,19 @@ public function getData(Feed $feed): array
5454

5555
$result = [];
5656

57-
// Check that image is accessible, otherwise leave out the feed element.
57+
// Check that image is available and accessible, otherwise leave out the feed element.
5858
foreach ($feedItems as $feedItem) {
59-
$response = $this->client->request(Request::METHOD_HEAD, $feedItem['mediaUrl']);
60-
$statusCode = $response->getStatusCode();
61-
62-
if (200 == $statusCode) {
63-
$result[] = $feedItem;
59+
if (!empty($feedItem['mediaUrl'])) {
60+
try {
61+
$response = $this->client->request(Request::METHOD_HEAD, $feedItem['mediaUrl']);
62+
$statusCode = $response->getStatusCode();
63+
64+
if (200 === $statusCode) {
65+
$result[] = $feedItem;
66+
}
67+
} catch (\Exception) {
68+
// Ignore item if request fails.
69+
}
6470
}
6571
}
6672

0 commit comments

Comments
 (0)