]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add a try catch block
authorLukas Reschke <lukas@owncloud.com>
Thu, 16 Oct 2014 19:45:09 +0000 (21:45 +0200)
committerLukas Reschke <lukas@owncloud.com>
Thu, 16 Oct 2014 19:45:09 +0000 (21:45 +0200)
This function might also be called before ownCloud is setup which results in a PHP fatal error. We therefore should gracefully catch errors in there.

lib/private/app.php

index 95a8a7302d96adf7e2b66496c6d870eea4dc92f7..faaadef38574025e875a1c3e1fe947adc03b076e 100644 (file)
@@ -1101,13 +1101,17 @@ class OC_App {
                        return $versions; // when function is used besides in checkUpgrade
                }
                $versions = array();
-               $query = OC_DB::prepare('SELECT `appid`, `configvalue` FROM `*PREFIX*appconfig`'
-                       . ' WHERE `configkey` = \'installed_version\'');
-               $result = $query->execute();
-               while ($row = $result->fetchRow()) {
-                       $versions[$row['appid']] = $row['configvalue'];
+               try {
+                       $query = OC_DB::prepare('SELECT `appid`, `configvalue` FROM `*PREFIX*appconfig`'
+                               . ' WHERE `configkey` = \'installed_version\'');
+                       $result = $query->execute();
+                       while ($row = $result->fetchRow()) {
+                               $versions[$row['appid']] = $row['configvalue'];
+                       }
+                       return $versions;
+               } catch (\Exception $e) {
+                       return array();
                }
-               return $versions;
        }