Skip to content

Commit

Permalink
UHF-10406: Fix crash when organization tag is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrsky committed Jan 10, 2025
1 parent 7dcadc0 commit 7bc63cc
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ public function getCityDescriptions() : array {
/**
* Get organization taxonomy term.
*
* @return \Drupal\taxonomy\TermInterface|bool
* @return \Drupal\taxonomy\TermInterface|false
* Returns the organization taxonomy term or false if not set.
*
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
*/
public function getOrganization() : TermInterface|bool {
public function getOrganization() : TermInterface|FALSE {
$organization_id = '';

// Get the organization id from the migrated field.
Expand All @@ -153,7 +153,8 @@ public function getOrganization() : TermInterface|bool {
$organization = $this->entityTypeManager()
->getStorage('taxonomy_term')
->load($organization_id);
return $organization;

return $organization ?? FALSE;
}
catch (\Exception $e) {
return FALSE;
Expand Down Expand Up @@ -257,7 +258,10 @@ public function getOrganizationDescription() : FilteredMarkup|string {
}
// If not and the organization description is empty,
// check if the organization taxonomy description is set and use it.
elseif ($organization_description->isEmpty() && !$organization->get('description')->isEmpty()) {
elseif (
$organization_description->isEmpty() &&
$organization && !$organization->get('description')->isEmpty()
) {
$organization_description = $organization->get('description');
}

Expand Down

0 comments on commit 7bc63cc

Please sign in to comment.