From fb2e6c8d13f2a7209cc5ea4adbeccd0e47be5c5f Mon Sep 17 00:00:00 2001 From: Md Nadim Hossain Date: Wed, 22 Nov 2023 15:16:38 +1100 Subject: [PATCH] Added null check. (#143) * Added null check. --- src/Commands/TideSiteCommands.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Commands/TideSiteCommands.php b/src/Commands/TideSiteCommands.php index c3ca42c..1ad7b57 100644 --- a/src/Commands/TideSiteCommands.php +++ b/src/Commands/TideSiteCommands.php @@ -44,8 +44,14 @@ public function siteEnvDomainUpdate() { foreach (explode(',', $fe_domains) as $fe_domain) { $domain = explode('|', $fe_domain); $term = Term::load($domain[0]); - $term->set('field_site_domains', str_replace('
', "\r\n", $domain[1])); - $term->save(); + // Check if the term exists before trying to manipulate it. + if ($term) { + $term->set('field_site_domains', str_replace('
', "\r\n", $domain[1])); + $term->save(); + } + else { + $this->output()->writeln($this->t('Term with ID @term_id not found.', ['@term_id' => $domain[0]])); + } } $this->output()->writeln($this->t('Domains Updated.')); }