fix: [api] Sharing group organisations not iterated if they don't exist

pull/3766/head
iglocska 2018-10-04 22:48:50 +02:00
parent 92eb8a91ad
commit 543fccdc58
1 changed files with 10 additions and 8 deletions

View File

@ -187,15 +187,17 @@ class SharingGroup extends AppModel
));
}
$sg['Organisation'] = $this->__sgoCache[$sg['SharingGroup']['org_id']];
foreach ($sg['SharingGroupOrg'] as &$sgo) {
if (!isset($this->__sgoCache[$sgo['org_id']])) {
$this->__sgoCache[$sgo['org_id']] = $this->Organisation->find('first', array(
'recursive' => -1,
'fields' => $fieldsOrg,
'conditions' => array('id' => $sgo['org_id'])
));
if (!empty($sg['SharingGroupOrg'])) {
foreach ($sg['SharingGroupOrg'] as &$sgo) {
if (!isset($this->__sgoCache[$sgo['org_id']])) {
$this->__sgoCache[$sgo['org_id']] = $this->Organisation->find('first', array(
'recursive' => -1,
'fields' => $fieldsOrg,
'conditions' => array('id' => $sgo['org_id'])
));
}
$sgo['Organisation'] = $this->__sgoCache[$sgo['org_id']];
}
$sgo['Organisation'] = $this->__sgoCache[$sgo['org_id']];
}
}
return $sgs;