Skip to content

Commit 49ef74c

Browse files
committed
Safeguard against no URLs being available
If fetching a sitemap fails, the URLs array is empty and `reset()` returns `false`.
1 parent 44abfe8 commit 49ef74c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

root-files/opt/flownative/sitemap-crawler/sitemap-crawler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public function __construct(string $sitemapUrl, string $internalBaseUrl)
6363
public function crawl(): void
6464
{
6565
$firstUrl = reset($this->urls);
66+
if ($firstUrl === false) {
67+
$this->log('No first URL to parse.');
68+
exit(0);
69+
}
70+
6671
$parsedFirstUrl = parse_url($firstUrl);
6772
$internalFirstUrl = $this->internalBaseUrl . $parsedFirstUrl['path'] . (isset($parsedFirstUrl['query']) ? '?' . $parsedFirstUrl['query'] : '');
6873

0 commit comments

Comments
 (0)