]> source.dussan.org Git - nextcloud-server.git/commitdiff
fixed error rising from fetchRow
authorFlorin Peter <github@florin-peter.de>
Sat, 25 May 2013 21:07:19 +0000 (23:07 +0200)
committerFlorin Peter <github@florin-peter.de>
Sat, 25 May 2013 21:20:55 +0000 (23:20 +0200)
apps/files_encryption/lib/util.php

index 9259f521d1aedaf1e7e90ee5b2b4827f252b959f..70fcd955be045493aad2cc25fa90c52e1af39e6c 100644 (file)
@@ -293,12 +293,11 @@ class Util
 
                if (\OC_DB::isError($result)) {
                        \OC_Log::write('Encryption library', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
-               }
-
-               while ( $row = $result->fetchRow() ) {
-
-                       $recoveryEnabled[] = $row['recovery_enabled'];
-
+               } else {
+                       $row = $result->fetchRow();
+                       if( isset( $row['recovery_enabled'] ) ) {
+                               $recoveryEnabled[] = $row['recovery_enabled'];
+                       }
                }
 
                // If no record is found
@@ -824,13 +823,15 @@ class Util
 
                $result = $query->execute( array( $fileId ) );
 
+               $path = false;
                if (\OC_DB::isError($result)) {
                        \OC_Log::write('Encryption library', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
+               } else {
+                       $row = $result->fetchRow();
+                       $path = substr( $row['path'], strlen('files') );
                }
 
-               $row = $result->fetchRow();
-
-               return substr( $row['path'], 5 );
+               return $path;
 
        }
 
@@ -1096,11 +1097,11 @@ class Util
 
                if (\OC_DB::isError($result)) {
                        \OC_Log::write('Encryption library', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
-               }
-
-               $row = $result->fetchRow();
-               if($row) {
-                       $migrationStatus[] = $row['migration_status'];
+               } else {
+                       $row = $result->fetchRow();
+                       if( isset( $row['migration_status'] ) ) {
+                               $migrationStatus[] = $row['migration_status'];
+                       }
                }
 
                // If no record is found
@@ -1233,12 +1234,13 @@ class Util
 
                $result = $query->execute( array( $id ) );
 
+               $row = array();
                if (\OC_DB::isError($result)) {
                        \OC_Log::write('Encryption library', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
+               } else {
+                       $row = $result->fetchRow();
                }
 
-               $row = $result->fetchRow();
-
                return $row;
 
        }
@@ -1256,12 +1258,13 @@ class Util
 
                $result = $query->execute( array( $id ) );
 
+               $row = array();
                if (\OC_DB::isError($result)) {
                        \OC_Log::write('Encryption library', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
+               } else {
+                       $row = $result->fetchRow();
                }
 
-               $row = $result->fetchRow();
-
                return $row;
 
        }
@@ -1278,12 +1281,13 @@ class Util
 
                $result = $query->execute( array( $id ) );
 
+               $source = array();
                if (\OC_DB::isError($result)) {
                        \OC_Log::write('Encryption library', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
+               } else {
+                       $source = $result->fetchRow();
                }
 
-               $source = $result->fetchRow();
-
                $fileOwner = false;
 
                if ( isset( $source['parent'] ) ) {
@@ -1296,12 +1300,13 @@ class Util
 
                                $result = $query->execute( array( $parent ) );
 
+                               $item = array();
                                if (\OC_DB::isError($result)) {
                                        \OC_Log::write('Encryption library', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
+                               } else {
+                                       $item = $result->fetchRow();
                                }
 
-                               $item = $result->fetchRow();
-
                                if ( isset( $item['parent'] ) ) {
 
                                        $parent = $item['parent'];