From 788c5940f08c5380b695c4bf9b69b53af1cd2d59 Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Sat, 25 May 2013 23:07:19 +0200 Subject: [PATCH] fixed error rising from fetchRow --- apps/files_encryption/lib/util.php | 49 ++++++++++++++++-------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 9259f521d1a..70fcd955be0 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -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']; -- 2.39.5