Skip to content

Commit

Permalink
Feed.json returning a null when there shouldn't be
Browse files Browse the repository at this point in the history
  • Loading branch information
brown-a2 committed Aug 29, 2023
1 parent e695a5b commit 793611e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions run.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@
$feedID = $feed['id'];
$feedURL = $feed['url'];
$xmlName = "$feedID.xml";
$xmlLocation = "/output/$xmlName";
$xmlFile = "output/$xmlName";
$jsonFile = "output/$feedID.json";

// Fetch the XML feed using wget
exec("wget -O $xmlLocation $feedURL");
exec("wget -O $xmlFile $feedURL");

// Get parser
$feed_parser = new OleeoFeedParser();

$optionalFields = [
Expand All @@ -105,9 +107,7 @@
$filters = $feed['filters'];
}

$jsonFile = "output/$feedID.json";

$parseResult = $feed_parser->parseToJSON("output/$xmlName", $jsonFile, $optionalFields, $feed['type'], $filters);
$parseResult = $feed_parser->parseToJSON($xmlFile, $jsonFile, $optionalFields, $feed['type'], $filters);

if (!$parseResult['success']) {
continue;
Expand All @@ -119,7 +119,7 @@

$availableFeeds[] = [
'name' => $feed['name'],
'url' => isset($uploadResult['fileURL']) ? $uploadResult['fileURL'] : null,
'url' => $uploadResult['fileURL']
];

// Export locally
Expand All @@ -136,8 +136,8 @@
}
}

// Export to s3
if ($envType !== 'local') {
// Export to s3
$uploadResult = uploadFiletoS3($s3Client, $s3BucketName, $s3BucketPath . "$feedID.json", $jsonFile);

if (!$uploadResult['success'] || empty($uploadResult['fileURL'])) {
Expand All @@ -150,13 +150,13 @@
$feedsJSON = json_encode($availableFeeds);

if (!$feedsJSON) {
exit;
return;
}

$writeFileResult = file_put_contents("output/feeds.json", $feedsJSON);

if ($writeFileResult === false) {
exit;
return;
}

if ($envType == 'local') {
Expand Down

0 comments on commit 793611e

Please sign in to comment.