Skip to content

Commit 4e4cb48

Browse files
committed
fix: replace usage of fetch()
1 parent b24d7c1 commit 4e4cb48

14 files changed

Lines changed: 37 additions & 47 deletions

File tree

apps/files_sharing/lib/ShareBackend/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ protected static function resolveReshares($source) {
205205
$parent = $source['parent'];
206206
while (isset($parent)) {
207207
$query = \OCP\DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
208-
$item = $query->execute([$parent])->fetchRow();
208+
$item = $query->execute([$parent])->fetch();
209209
if (isset($item['parent'])) {
210210
$parent = $item['parent'];
211211
} else {

apps/files_sharing/lib/ShareBackend/Folder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getParents($itemSource, $shareWith = null, $owner = null) {
7171
private function getParentId($child) {
7272
$query = \OCP\DB::prepare('SELECT `parent` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
7373
$result = $query->execute([$child]);
74-
$row = $result->fetchRow();
74+
$row = $result->fetch();
7575
$parent = ($row) ? $row['parent'] : null;
7676

7777
return $parent;
@@ -82,7 +82,7 @@ public function getChildren($itemSource) {
8282
$parents = [$itemSource];
8383
$query = \OCP\DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
8484
$result = $query->execute(['httpd/unix-directory']);
85-
if ($row = $result->fetchRow()) {
85+
if ($row = $result->fetch()) {
8686
$mimetype = $row['id'];
8787
} else {
8888
$mimetype = -1;
@@ -93,7 +93,7 @@ public function getChildren($itemSource) {
9393
.' WHERE `parent` IN ('.$parents.')');
9494
$result = $query->execute();
9595
$parents = [];
96-
while ($file = $result->fetchRow()) {
96+
while ($file = $result->fetch()) {
9797
$children[] = ['source' => $file['fileid'], 'file_path' => $file['name']];
9898
// If a child folder is found look inside it
9999
if ($file['mimetype'] == $mimetype) {

apps/files_sharing/tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ protected function getShareFromId($shareID) {
219219
$share = null;
220220

221221
if ($result) {
222-
$share = $result->fetchRow();
222+
$share = $result->fetch();
223223
}
224224

225225
return $share;

apps/files_trashbin/lib/Trashbin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public static function getLocations($user) {
145145
. ' FROM `*PREFIX*files_trash` WHERE `user`=?');
146146
$result = $query->execute([$user]);
147147
$array = [];
148-
while ($row = $result->fetchRow()) {
148+
while ($row = $result->fetch()) {
149149
if (isset($array[$row['id']])) {
150150
$array[$row['id']][$row['timestamp']] = $row['location'];
151151
} else {

lib/private/Files/Cache/HomeCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function calculateFolderSize($path, $entry = null) {
5555
'FROM `*PREFIX*filecache` ' .
5656
'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0';
5757
$result = \OC_DB::executeAudited($sql, [$id, $this->getNumericStorageId()]);
58-
if ($row = $result->fetchRow()) {
58+
if ($row = $result->fetch()) {
5959
$result->free();
6060
list($sum) = \array_values($row);
6161
$totalSize = 0 + $sum;

lib/private/Files/Cache/Storage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private static function getStorageByIdFromCache($storageId) {
154154
private static function getStorageByIdFromDb($storageId) {
155155
$sql = 'SELECT * FROM `*PREFIX*storages` WHERE `id` = ?';
156156
$resultSet = \OC_DB::executeAudited($sql, [$storageId]);
157-
return $resultSet->fetchRow();
157+
return $resultSet->fetch();
158158
}
159159

160160
private static function unsetCache($storageId) {
@@ -197,7 +197,7 @@ public function getNumericId() {
197197
public static function getStorageId($numericId) {
198198
$sql = 'SELECT `id` FROM `*PREFIX*storages` WHERE `numeric_id` = ?';
199199
$result = \OC_DB::executeAudited($sql, [$numericId]);
200-
if ($row = $result->fetchRow()) {
200+
if ($row = $result->fetch()) {
201201
return $row['id'];
202202
} else {
203203
return null;

lib/private/Group/Database.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public function getGroups($search = '', $limit = null, $offset = null) {
259259
$stmt = \OC_DB::prepare('SELECT `gid` FROM `*PREFIX*groups`' . $searchLike . ' ORDER BY `gid` ASC', $limit, $offset);
260260
$result = $stmt->execute($parameters);
261261
$groups = [];
262-
while ($row = $result->fetchRow()) {
262+
while ($row = $result->fetch()) {
263263
$groups[] = $row['gid'];
264264
}
265265
return $groups;
@@ -318,7 +318,7 @@ public function usersInGroup($gid, $search = '', $limit = null, $offset = null)
318318
);
319319
$result = $stmt->execute($parameters);
320320
$users = [];
321-
while ($row = $result->fetchRow()) {
321+
while ($row = $result->fetch()) {
322322
$users[] = $row['uid'];
323323
}
324324
return $users;

lib/private/Share/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function delete($parent, $excludeParent = false, $uidOwner = null,
110110
$result = $query->execute($params);
111111
// Reset parents array, only go through loop again if items are found
112112
$parents = [];
113-
while ($item = $result->fetchRow()) {
113+
while ($item = $result->fetch()) {
114114
$tmpItem = [
115115
'id' => $item['id'],
116116
'shareWith' => $item['share_with'],

lib/private/Share/Share.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public static function getUsersSharingFile($path, $ownerUser, $includeOwner = fa
212212
if (\OCP\DB::isError($result)) {
213213
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
214214
} else {
215-
while ($row = $result->fetchRow()) {
215+
while ($row = $result->fetch()) {
216216
if ((int)($row['accepted']) === Constants::STATE_REJECTED) {
217217
$rejected[]= $row['parent'];
218218
continue;
@@ -267,7 +267,7 @@ public static function getUsersSharingFile($path, $ownerUser, $includeOwner = fa
267267
if (\OCP\DB::isError($result)) {
268268
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
269269
} else {
270-
if ($result->fetchRow()) {
270+
if ($result->fetch()) {
271271
$publicShare = true;
272272
}
273273
}
@@ -288,7 +288,7 @@ public static function getUsersSharingFile($path, $ownerUser, $includeOwner = fa
288288
if (\OCP\DB::isError($result)) {
289289
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
290290
} else {
291-
if ($result->fetchRow()) {
291+
if ($result->fetch()) {
292292
$remoteShare = true;
293293
}
294294
}
@@ -324,7 +324,7 @@ public static function getUsersSharingFile($path, $ownerUser, $includeOwner = fa
324324
if (\OCP\DB::isError($result)) {
325325
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
326326
} else {
327-
while ($row = $result->fetchRow()) {
327+
while ($row = $result->fetch()) {
328328
foreach ($fileTargets[$row['fileid']] as $uid => $shareData) {
329329
if ($mountPath !== false) {
330330
$sharedPath = $shareData['file_target'];
@@ -489,7 +489,7 @@ public static function getItemSharedWithUser($itemType, $itemSource, $user, $own
489489

490490
$result = \OC_DB::executeAudited($query, $arguments);
491491

492-
while ($row = $result->fetchRow()) {
492+
while ($row = $result->fetch()) {
493493
if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) {
494494
continue;
495495
}
@@ -610,7 +610,7 @@ public static function getShareByToken($token, $checkPasswordProtection = true)
610610
if ($result === false) {
611611
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OCP\Util::ERROR);
612612
}
613-
$row = $result->fetchRow();
613+
$row = $result->fetch();
614614
if ($row === false) {
615615
return false;
616616
}
@@ -636,7 +636,7 @@ public static function resolveReShare($linkItem) {
636636
$parent = $linkItem['parent'];
637637
while (isset($parent)) {
638638
$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `id` = ?', 1);
639-
$item = $query->execute([$parent])->fetchRow();
639+
$item = $query->execute([$parent])->fetch();
640640
if (isset($item['parent'])) {
641641
$parent = $item['parent'];
642642
} else {
@@ -1144,7 +1144,7 @@ public static function unshareAll($itemType, $itemSource) {
11441144
$result = $query->execute([$itemType, $itemSource]);
11451145
$shares = [];
11461146
// Add each owner's shares to the array of all shares for this item.
1147-
while ($row = $result->fetchRow()) {
1147+
while ($row = $result->fetch()) {
11481148
$shares = \array_merge($shares, self::getItems($itemType, $itemSource, null, null, $row['uid_owner']));
11491149
}
11501150
if (!empty($shares)) {
@@ -2024,7 +2024,7 @@ public static function getItems(
20242024
$targets = [];
20252025
$switchedItems = [];
20262026
$mounts = [];
2027-
while ($row = $result->fetchRow()) {
2027+
while ($row = $result->fetch()) {
20282028
self::transformDBResults($row);
20292029
// Filter out duplicate group shares for users with unique targets
20302030
if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) {
@@ -2086,7 +2086,7 @@ public static function getItems(
20862086
\OCP\Util::ERROR
20872087
);
20882088
} else {
2089-
$parentRow = $parentResult->fetchRow();
2089+
$parentRow = $parentResult->fetch();
20902090
$tmpPath = $parentRow['file_target'];
20912091
// find the right position where the row path continues from the target path
20922092
$pos = \strrpos($row['path'], $parentRow['file_target']);
@@ -2723,7 +2723,7 @@ public static function removeAllLinkShares() {
27232723
// Delete any link shares
27242724
$query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*share` WHERE `share_type` = ?');
27252725
$result = $query->execute([self::SHARE_TYPE_LINK]);
2726-
while ($item = $result->fetchRow()) {
2726+
while ($item = $result->fetch()) {
27272727
Helper::delete($item['id']);
27282728
}
27292729
}

lib/private/Tags.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public function getIdsForTag($tag) {
300300
}
301301

302302
if ($result !== null) {
303-
while ($row = $result->fetchRow()) {
303+
while ($row = $result->fetch()) {
304304
$id = (int)$row['objid'];
305305

306306
if ($this->includeShared) {
@@ -548,7 +548,7 @@ public static function post_deleteUser($arguments) {
548548
try {
549549
$stmt = \OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` '
550550
. 'WHERE `categoryid` = ?');
551-
while ($row = $result->fetchRow()) {
551+
while ($row = $result->fetch()) {
552552
try {
553553
$stmt->execute([$row['id']]);
554554
} catch (\Exception $e) {

0 commit comments

Comments
 (0)