🔧 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 {

View file

@ -99,7 +99,7 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
$twingleApi = Civi::cache()->get('twinglecampaign_twingle_api');
if (NULL === $twingleApi || $params['twingle_api_key'] || $params['limit']) {
try {
if ($params['limit']) {
if (isset($params['limit'])) {
$twingleApi = new TwingleApiCall($apiKey, $params['limit']);
}
else {
@ -112,7 +112,7 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
}
// If an id or a event_id is provided, synchronize only this one campaign
if ($params['id'] || $params['event_id']) {
if (isset($params['id']) || isset($params['event_id'])) {
// Get project from db via API
$params['sequential'] = 1;

View file

@ -91,7 +91,7 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
}
// If an id or a project_id is given, synchronize only this one campaign
if ($params['id'] || $params['project_id']) {
if (isset($params['id']) || isset($params['project_id'])) {
// Get project from db via API
$params['sequential'] = 1;