]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check whether return is an error case before using it
authorJoas Schilling <nickvergessen@gmx.de>
Fri, 30 Jan 2015 15:39:57 +0000 (16:39 +0100)
committerJoas Schilling <nickvergessen@gmx.de>
Fri, 30 Jan 2015 15:39:57 +0000 (16:39 +0100)
settings/controller/appsettingscontroller.php

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