Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions lib/private/Repair/RepairInvalidShares.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace OC\Repair;

use OCP\Constants;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
Expand Down Expand Up @@ -67,18 +68,20 @@ private function removeSharesNonExistingParent(IOutput $output): void {

$deleteQuery = $this->connection->getQueryBuilder();
$deleteQuery->delete('share')
->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent')));
->where($deleteQuery->expr()->in('parent', $deleteQuery->createParameter('parent')));

$deletedInLastChunk = self::CHUNK_SIZE;
while ($deletedInLastChunk === self::CHUNK_SIZE) {
$deletedInLastChunk = 0;
while (true) {
$result = $query->executeQuery();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter isn't set on the first invocation, so this will fail, no?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a different query there is two $query with a limit of 1000 and $deleteQuery which then delete the results

while ($row = $result->fetch()) {
$deletedInLastChunk++;
$deletedEntries += $deleteQuery->setParameter('parent', (int)$row['parent'])
->executeStatement();
}
$parents = $result->fetchFirstColumn();
$parents = array_unique($parents);
$result->closeCursor();

if ($parents === []) {
break;
}

$deletedEntries += $deleteQuery->setParameter('parent', $parents, IQueryBuilder::PARAM_INT_ARRAY)
->executeStatement();
}

if ($deletedEntries) {
Expand Down
Loading