🔧 fixing some 'unknown index' warnings

This commit is contained in:
Marc Michalsky forumZFD 2021-03-18 15:51:28 +01:00
parent 3083feae5e
commit 1e6feda923
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
4 changed files with 17 additions and 11 deletions

View file

@ -181,8 +181,10 @@ abstract class CRM_TwingleCampaign_BAO_Campaign {
// Translate keys
foreach ($field_translations as $origin => $translation) {
$values[$translation] = $values[$origin];
unset($values[$origin]);
if (isset($values[$origin])) {
$values[$translation] = $values[$origin];
unset($values[$origin]);
}
}
}

View file

@ -27,11 +27,13 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
$this->id_custom_field = Cache::getInstance()
->getCustomFieldMapping()['twingle_event_id'];
try {
$this->values['parent_id'] = $this->getParentCampaignId();
} catch (CiviCRM_API3_Exception $e) {
$errorMessage = $e->getMessage();
throw new Exception("Could not identify parent Campaign: $errorMessage");
if ($id) {
try {
$this->values['parent_id'] = $this->getParentCampaignId();
} catch (CiviCRM_API3_Exception $e) {
$errorMessage = $e->getMessage();
throw new Exception("Could not identify parent Campaign: $errorMessage");
}
}
}
@ -152,7 +154,9 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
self::getTimestamp($values['created_at']);
// Cast project target to integer
$values['project_target'] = (int) $values['project_target'];
if (isset($values['project_target'])) {
$values['project_target'] = (int) $values['project_target'];
}
}
else {