Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update occ files:repair-tree command to also handle cases where the parent is -1 when it shouldn't be #39231

Closed
wants to merge 1 commit into from

Conversation

icewind1991
Copy link
Member

items should only have a parent of -1 when the path is ''. This adds some logic to determine the proper parent id to repair the invalid items.

…arent is -1 when it shouldn't be

Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Jul 7, 2023
@icewind1991 icewind1991 added this to the Nextcloud 28 milestone Jul 7, 2023
@icewind1991 icewind1991 requested review from ArtificialOwl, a team, blizzz and come-nc and removed request for a team July 7, 2023 14:31
return 0;
}

private function repairParent(bool $fix, OutputInterface $output) {

Check notice

Code scanning / Psalm

MissingReturnType Note

Method OCA\Files\Command\RepairTree::repairParent does not have a return type, expecting void
'fileid' => $row['fileid'],
'parent' => $row['parent_id'],
]);
$query->execute();

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\DB\QueryBuilder\IQueryBuilder::execute has been marked as deprecated
}
}

private function repairPaths(bool $fix, OutputInterface $output) {

Check notice

Code scanning / Psalm

MissingReturnType Note

Method OCA\Files\Command\RepairTree::repairPaths does not have a return type, expecting void
))
->andWhere($query->expr()->neq('f.parent', $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT)));

return $query->execute()->fetchAll();

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\DB\QueryBuilder\IQueryBuilder::execute has been marked as deprecated
))
->andWhere($query->expr()->neq('f.parent', $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT)));

return $query->execute()->fetchAll();

Check notice

Code scanning / Psalm

PossiblyInvalidMethodCall Note

Cannot call method on possible int variable
Copy link
Member

@ArtificialOwl ArtificialOwl left a comment

Choose a reason for hiding this comment

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

tested

return 0;
}

private function repairParent(bool $fix, OutputInterface $output) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private function repairParent(bool $fix, OutputInterface $output) {
private function repairParent(bool $fix, OutputInterface $output): void {

'fileid' => $row['fileid'],
'parent' => $row['parent_id'],
]);
$query->execute();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$query->execute();
$query->executeStatement();

Comment on lines +72 to +77
}

$query = $this->connection->getQueryBuilder();
$query->update('filecache')
->set('parent', $query->createParameter('parent'))
->where($query->expr()->eq('fileid', $query->createParameter('fileid')));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
$query = $this->connection->getQueryBuilder();
$query->update('filecache')
->set('parent', $query->createParameter('parent'))
->where($query->expr()->eq('fileid', $query->createParameter('fileid')));
$query = $this->connection->getQueryBuilder();
$query->update('filecache')
->set('parent', $query->createParameter('parent'))
->where($query->expr()->eq('fileid', $query->createParameter('fileid')));
}

The query is only used for fixing, no?

}
}

private function repairPaths(bool $fix, OutputInterface $output) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private function repairPaths(bool $fix, OutputInterface $output) {
private function repairPaths(bool $fix, OutputInterface $output): void {

))
->andWhere($query->expr()->neq('f.parent', $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT)));

return $query->execute()->fetchAll();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return $query->execute()->fetchAll();
return $query->executeQuery()->fetchAll();

$query->expr()->eq('f.storage', 'p.storage')
))
->where($query->expr()->neq('f.path_hash', $query->createNamedParameter(md5(''))))
->andWhere($query->expr()->eq('f.parent', $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT)));

return $query->execute()->fetchAll();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return $query->execute()->fetchAll();
return $query->executeQuery()->fetchAll();

@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
This was referenced Nov 6, 2023
This was referenced Nov 14, 2023
@blizzz blizzz modified the milestones: Nextcloud 28, Nextcloud 29 Nov 23, 2023
This was referenced Mar 12, 2024
This was referenced Mar 20, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
@skjnldsv skjnldsv added 2. developing Work in progress stale Ticket or PR with no recent activity and removed 3. to review Waiting for reviews labels Jul 27, 2024
@blizzz blizzz mentioned this pull request Jul 30, 2024
@blizzz blizzz mentioned this pull request Aug 1, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv closed this Aug 14, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 30 milestone Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress stale Ticket or PR with no recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants