]> source.dussan.org Git - nextcloud-server.git/commitdiff
correctly handle error results of PDO and MDB2 backends
authorJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 20 Jun 2013 09:31:23 +0000 (12:31 +0300)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 28 Jun 2013 18:16:01 +0000 (20:16 +0200)
lib/db.php

index 4d6788f2bdacd3a7251b7f554c5cc7a43dd62b8d..5e624bf30b9cbb17ac97a1412834cf4964c633b4 100644 (file)
@@ -962,11 +962,14 @@ class OC_DB {
         * @return bool
         */
        public static function isError($result) {
-               if(self::$backend==self::BACKEND_PDO and $result === false) {
+               //PDO returns false on error (and throws an exception)
+               if (self::$backend===self::BACKEND_PDO and $result === false) {
                        return true;
-               }elseif(self::$backend==self::BACKEND_MDB2 and PEAR::isError($result)) {
+               } else
+               //MDB2 returns an MDB2_Error object
+               if (self::$backend===self::BACKEND_MDB2 and PEAR::isError($result)) {
                        return true;
-               }else{
+               } else {
                        return false;
                }
        }