Skip to content

Commit

Permalink
TTK-27420: Add condition to check if profile tags exist (#690)
Browse files Browse the repository at this point in the history
* TTK-27420: Add condition to check if profile tags exist

* TTK-27420: Add condition to check if target profile property exists

---------

Co-authored-by: Pablo Ogando Ferreira <[email protected]>
  • Loading branch information
albacodina and Yurujai authored Dec 18, 2024
1 parent b7afeda commit 153f19d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Pumukit/SchemaBundle/Services/MediaCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ public function generateProfileTags(Job $job, array $profile): Tags
if ($profile['display']) {
$tags[] = 'display';
}
foreach (array_filter(preg_split('/[,\s]+/', $profile['tags'])) as $tag) {
$tags[] = trim($tag);
if (!empty($profile['tags'])) {
foreach (array_filter(preg_split('/[,\s]+/', $profile['tags'])) as $tag) {
$tags[] = trim($tag);
}
}

return Tags::create($tags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ private function ensureProfileExists(MultimediaObject $multimediaObject): ?array

private function hasEncodedJobForProfile(MediaInterface $master, Tag $pubChannel, array $profile): bool
{
return $master->tags()->containsTag('ENCODED_'.$pubChannel->getCod()) && str_contains($profile['target'], $pubChannel->getCod());
return $master->tags()->containsTag('ENCODED_'.$pubChannel->getCod()) && isset($profile['target'])
&& is_string($profile['target']) && str_contains($profile['target'], $pubChannel->getCod());
}

private function hasMediaWithProfileTarget(MultimediaObject $multimediaObject, Tag $pubChannel): bool
Expand All @@ -204,6 +205,10 @@ private function hasMediaWithProfileTarget(MultimediaObject $multimediaObject, T
continue;
}

if (!isset($this->profiles[$profileName]['target']) || !is_string($this->profiles[$profileName]['target'])) {
continue;
}

$targets = $this->getTargets($this->profiles[$profileName]['target']);
if (!in_array($pubChannel->getCod(), $targets['standard'])) {
continue;
Expand Down

0 comments on commit 153f19d

Please sign in to comment.