Skip to content

Commit

Permalink
chore: add batch
Browse files Browse the repository at this point in the history
  • Loading branch information
solracsf committed Oct 16, 2024
1 parent c23b1f1 commit 14b6cee
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 48 deletions.
27 changes: 6 additions & 21 deletions apps/dav/lib/Migration/BuildCalendarSearchIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,11 @@

class BuildCalendarSearchIndex implements IRepairStep {

/** @var IDBConnection */
private $db;

/** @var IJobList */
private $jobList;

/** @var IConfig */
private $config;

/**
* @param IDBConnection $db
* @param IJobList $jobList
* @param IConfig $config
*/
public function __construct(IDBConnection $db,
IJobList $jobList,
IConfig $config) {
$this->db = $db;
$this->jobList = $jobList;
$this->config = $config;
public function __construct(
private IDBConnection $db,
private IJobList $jobList,
private IConfig $config,
) {
}

/**
Expand All @@ -55,7 +40,7 @@ public function run(IOutput $output) {
$query = $this->db->getQueryBuilder();
$query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')'))
->from('calendarobjects');
$result = $query->execute();
$result = $query->executeQuery();
$maxId = (int)$result->fetchOne();
$result->closeCursor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function run($argument) {
$qb->selectDistinct('remote')
->from('share_external');

$result = $qb->execute();
$result = $qb->executeQuery();
while ($row = $result->fetch()) {
$this->discoveryService->discover($row['remote'], 'FEDERATED_SHARING', true);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

class PopulateNewlyIntroducedDatabaseFields implements IRepairStep {

/** @var IDBConnection */
private $dbc;

public function __construct(IDBConnection $dbc) {
$this->dbc = $dbc;
public function __construct(
private IDBConnection $dbc,
) {
}

public function getName() {
Expand All @@ -41,7 +39,7 @@ protected function populateScopeTable(IResult $ids): void {
$insertQuery = $qb->insert('flow_operations_scope');
while (($id = $ids->fetchOne()) !== false) {
$insertQuery->values(['operation_id' => $qb->createNamedParameter($id), 'type' => IManager::SCOPE_ADMIN]);
$insertQuery->execute();
$insertQuery->executeStatement();
}
}

Expand All @@ -55,7 +53,7 @@ protected function getIdsWithoutScope(): IResult {
// in case the repair step is executed multiple times for whatever reason.

/** @var IResult $result */
$result = $selectQuery->execute();
$result = $selectQuery->executeQuery();
return $result;
}
}
32 changes: 16 additions & 16 deletions lib/private/Group/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ class Database extends ABackend implements
INamedBackend {
/** @var array<string, array{gid: string, displayname: string}> */
private $groupCache = [];
private ?IDBConnection $dbConn;

/**
* \OC\Group\Database constructor.
*
* @param IDBConnection|null $dbConn
*/
public function __construct(?IDBConnection $dbConn = null) {
$this->dbConn = $dbConn;
public function __construct(
private ?IDBConnection $dbConn = null,
) {
}

/**
Expand Down Expand Up @@ -102,19 +102,19 @@ public function deleteGroup(string $gid): bool {
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('groups')
->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
->execute();
->executeStatement();

// Delete the group-user relation
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('group_user')
->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
->execute();
->executeStatement();

// Delete the group-groupadmin relation
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('group_admin')
->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
->execute();
->executeStatement();

// Delete from cache
unset($this->groupCache[$gid]);
Expand All @@ -139,7 +139,7 @@ public function inGroup($uid, $gid) {
->from('group_user')
->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
->execute();
->executeQuery();

$result = $cursor->fetch();
$cursor->closeCursor();
Expand All @@ -164,7 +164,7 @@ public function addToGroup(string $uid, string $gid): bool {
$qb->insert('group_user')
->setValue('uid', $qb->createNamedParameter($uid))
->setValue('gid', $qb->createNamedParameter($gid))
->execute();
->executeStatement();
return true;
} else {
return false;
Expand All @@ -186,7 +186,7 @@ public function removeFromGroup(string $uid, string $gid): bool {
$qb->delete('group_user')
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
->andWhere($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
->execute();
->executeStatement();

return true;
}
Expand All @@ -213,7 +213,7 @@ public function getUserGroups($uid) {
->from('group_user', 'gu')
->leftJoin('gu', 'groups', 'g', $qb->expr()->eq('gu.gid', 'g.gid'))
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
->execute();
->executeQuery();

$groups = [];
while ($row = $cursor->fetch()) {
Expand Down Expand Up @@ -260,7 +260,7 @@ public function getGroups(string $search = '', int $limit = -1, int $offset = 0)
if ($offset > 0) {
$query->setFirstResult($offset);
}
$result = $query->execute();
$result = $query->executeQuery();

$groups = [];
while ($row = $result->fetch()) {
Expand Down Expand Up @@ -292,7 +292,7 @@ public function groupExists($gid) {
$cursor = $qb->select('gid', 'displayname')
->from('groups')
->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
->execute();
->executeQuery();
$result = $cursor->fetch();
$cursor->closeCursor();

Expand Down Expand Up @@ -423,7 +423,7 @@ public function countUsersInGroup(string $gid, string $search = ''): int {
)));
}

$result = $query->execute();
$result = $query->executeQuery();
$count = $result->fetchOne();
$result->closeCursor();

Expand Down Expand Up @@ -455,7 +455,7 @@ public function countDisabledInGroup(string $gid): int {
->andWhere($query->expr()->eq('configvalue', $query->createNamedParameter('false'), IQueryBuilder::PARAM_STR))
->andWhere($query->expr()->eq('gid', $query->createNamedParameter($gid), IQueryBuilder::PARAM_STR));

$result = $query->execute();
$result = $query->executeQuery();
$count = $result->fetchOne();
$result->closeCursor();

Expand Down Expand Up @@ -484,7 +484,7 @@ public function getDisplayName(string $gid): string {
->from('groups')
->where($query->expr()->eq('gid', $query->createNamedParameter($gid)));

$result = $query->execute();
$result = $query->executeQuery();
$displayName = $result->fetchOne();
$result->closeCursor();

Expand Down Expand Up @@ -555,7 +555,7 @@ public function setDisplayName(string $gid, string $displayName): bool {
$query->update('groups')
->set('displayname', $query->createNamedParameter($displayName))
->where($query->expr()->eq('gid', $query->createNamedParameter($gid)));
$query->execute();
$query->executeStatement();

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Repair/OldGroupMembershipShares.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function run(IOutput $output) {
while ($row = $result->fetch()) {
if (!$this->isMember($row['group'], $row['user'])) {
$deletedEntries += $deleteQuery->setParameter('share', (int)$row['id'])
->execute();
->executeStatement();
}
}
$result->closeCursor();
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Repair/RepairInvalidShares.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
namespace OC\Repair;

use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

/**
* Repairs shares with invalid data
Expand Down

0 comments on commit 14b6cee

Please sign in to comment.