Removed numRows usage from encryption app

numRows on Oracle always seem to return 0.

This fix removes numRows usage from the encryption and sharing app.

This fixes unit tests and potentially the encryption app itself
(migration status) when running on Oracle
This commit is contained in:
Vincent Petry 2013-12-18 18:23:07 +01:00
parent ae3df84e20
commit 963ee31efb
2 changed files with 19 additions and 31 deletions

View File

@ -241,13 +241,11 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
if ($result->numRows() > 0) {
$row = $result->fetchRow();
if (isset($row['recovery_enabled'])) {
if ($row && isset($row['recovery_enabled'])) {
$recoveryEnabled[] = $row['recovery_enabled'];
}
}
}
// If no record is found
if (empty($recoveryEnabled)) {
@ -289,7 +287,7 @@ class Util {
$sql = 'UPDATE `*PREFIX*encryption` SET `recovery_enabled` = ? WHERE `uid` = ?';
$args = array(
$enabled,
$enabled ? '1' : '0',
$this->userId
);
@ -944,8 +942,8 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
if ($result->numRows() > 0) {
$row = $result->fetchRow();
if ($row) {
$path = substr($row['path'], strlen('files'));
}
}
@ -1225,13 +1223,11 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
if ($result->numRows() > 0) {
$row = $result->fetchRow();
if (isset($row['migration_status'])) {
if ($row && isset($row['migration_status'])) {
$migrationStatus[] = $row['migration_status'];
}
}
}
// If no record is found
if (empty($migrationStatus)) {
@ -1409,10 +1405,8 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
if ($result->numRows() > 0) {
$row = $result->fetchRow();
}
}
return $row;
@ -1435,10 +1429,8 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
if ($result->numRows() > 0) {
$row = $result->fetchRow();
}
}
return $row;
@ -1456,18 +1448,16 @@ class Util {
$result = $query->execute(array($id));
$source = array();
$source = null;
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
if ($result->numRows() > 0) {
$source = $result->fetchRow();
}
}
$fileOwner = false;
if (isset($source['parent'])) {
if ($source && isset($source['parent'])) {
$parent = $source['parent'];
@ -1477,16 +1467,14 @@ class Util {
$result = $query->execute(array($parent));
$item = array();
$item = null;
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
if ($result->numRows() > 0) {
$item = $result->fetchRow();
}
}
if (isset($item['parent'])) {
if ($item && isset($item['parent'])) {
$parent = $item['parent'];

View File

@ -132,7 +132,7 @@ abstract class Test_Files_Sharing_Base extends \PHPUnit_Framework_TestCase {
$share = Null;
if ($result && $result->numRows() > 0) {
if ($result) {
$share = $result->fetchRow();
}