image.class.php (fogproject-1.5.5) | : | image.class.php (fogproject-1.5.6) | ||
---|---|---|---|---|
skipping to change at line 380 | skipping to change at line 380 | |||
} | } | |||
/** | /** | |||
* Gets the storage group | * Gets the storage group | |||
* | * | |||
* @throws Exception | * @throws Exception | |||
* @return object | * @return object | |||
*/ | */ | |||
public function getStorageGroup() | public function getStorageGroup() | |||
{ | { | |||
$groupids = $this->get('storagegroups'); | $groupids = $this->get('storagegroups'); | |||
$count = count($groupids); | if (is_array($groupids) && count($groupids) < 1) { | |||
if ($count < 1) { | ||||
$groupids = self::getSubObjectIDs('StorageGroup'); | $groupids = self::getSubObjectIDs('StorageGroup'); | |||
$groupids = @min($groupids); | $groupids = @min($groupids); | |||
if ($groupids < 1) { | if ($groupids < 1) { | |||
throw new Exception(_('No viable storage groups found')); | throw new Exception(_('No viable storage groups found')); | |||
} | } | |||
} | } | |||
$primaryGroup = array(); | $primaryGroup = array(); | |||
foreach ((array)$groupids as &$groupid) { | foreach ((array)$groupids as &$groupid) { | |||
if (!$this->getPrimaryGroup($groupid)) { | if (!$this->getPrimaryGroup($groupid)) { | |||
continue; | continue; | |||
} | } | |||
$primaryGroup[] = $groupid; | $primaryGroup[] = $groupid; | |||
unset($groupid); | unset($groupid); | |||
} | } | |||
if (count($primaryGroup) < 1) { | if (is_array($primaryGroup) && count($primaryGroup) < 1) { | |||
$primaryGroup = @min((array) $groupids); | $primaryGroup = @min((array) $groupids); | |||
} else { | } else { | |||
$primaryGroup = array_shift($primaryGroup); | $primaryGroup = array_shift($primaryGroup); | |||
} | } | |||
return new StorageGroup($primaryGroup); | return new StorageGroup($primaryGroup); | |||
} | } | |||
/** | /** | |||
* Gets the primary storage group. | * Gets the primary storage group. | |||
* | * | |||
End of changes. 2 change blocks. | ||||
3 lines changed or deleted | 2 lines changed or added |