Check whether return is an error case before using it

This commit is contained in:
Joas Schilling 2015-01-30 16:39:57 +01:00
parent e7900ba255
commit 7bd7c20295
1 changed files with 12 additions and 8 deletions

View File

@ -67,11 +67,13 @@ class AppSettingsController extends Controller {
$categories[] = ['id' => 2, 'displayName' => (string)$this->l10n->t('Recommended')]; $categories[] = ['id' => 2, 'displayName' => (string)$this->l10n->t('Recommended')];
// apps from external repo via OCS // apps from external repo via OCS
$ocs = \OC_OCSClient::getCategories(); $ocs = \OC_OCSClient::getCategories();
foreach($ocs as $k => $v) { if ($ocs) {
$categories[] = array( foreach($ocs as $k => $v) {
'id' => $k, $categories[] = array(
'displayName' => str_replace('ownCloud ', '', $v) 'id' => $k,
); 'displayName' => str_replace('ownCloud ', '', $v)
);
}
} }
} }
@ -124,9 +126,11 @@ class AppSettingsController extends Controller {
default: default:
if ($category === 2) { if ($category === 2) {
$apps = \OC_App::getAppstoreApps('approved'); $apps = \OC_App::getAppstoreApps('approved');
$apps = array_filter($apps, function ($app) { if ($apps) {
return isset($app['internalclass']) && $app['internalclass'] === 'recommendedapp'; $apps = array_filter($apps, function ($app) {
}); return isset($app['internalclass']) && $app['internalclass'] === 'recommendedapp';
});
}
} else { } else {
$apps = \OC_App::getAppstoreApps('approved', $category); $apps = \OC_App::getAppstoreApps('approved', $category);
} }