aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Maintenance/RepairShareOwnership.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Maintenance/RepairShareOwnership.php')
-rw-r--r--core/Command/Maintenance/RepairShareOwnership.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/core/Command/Maintenance/RepairShareOwnership.php b/core/Command/Maintenance/RepairShareOwnership.php
index 56a95b68ed7..16675545afe 100644
--- a/core/Command/Maintenance/RepairShareOwnership.php
+++ b/core/Command/Maintenance/RepairShareOwnership.php
@@ -14,6 +14,7 @@ use OCP\IDBConnection;
use OCP\IUser;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -33,7 +34,7 @@ class RepairShareOwnership extends Command {
->setName('maintenance:repair-share-owner')
->setDescription('repair invalid share-owner entries in the database')
->addOption('no-confirm', 'y', InputOption::VALUE_NONE, "Don't ask for confirmation before repairing the shares")
- ->addArgument('user', InputArgument::OPTIONAL, "User to fix incoming shares for, if omitted all users will be fixed");
+ ->addArgument('user', InputArgument::OPTIONAL, 'User to fix incoming shares for, if omitted all users will be fixed');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
@@ -51,15 +52,16 @@ class RepairShareOwnership extends Command {
}
if ($shares) {
- $output->writeln("");
- $output->writeln("Found " . count($shares) . " shares with invalid share owner");
+ $output->writeln('');
+ $output->writeln('Found ' . count($shares) . ' shares with invalid share owner');
foreach ($shares as $share) {
/** @var array{shareId: int, fileTarget: string, initiator: string, receiver: string, owner: string, mountOwner: string} $share */
$output->writeln(" - share {$share['shareId']} from \"{$share['initiator']}\" to \"{$share['receiver']}\" at \"{$share['fileTarget']}\", owned by \"{$share['owner']}\", that should be owned by \"{$share['mountOwner']}\"");
}
- $output->writeln("");
+ $output->writeln('');
if (!$noConfirm) {
+ /** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion('Repair these shares? [y/N]', false);
@@ -67,10 +69,10 @@ class RepairShareOwnership extends Command {
return 0;
}
}
- $output->writeln("Repairing " . count($shares) . " shares");
+ $output->writeln('Repairing ' . count($shares) . ' shares');
$this->repairShares($shares);
} else {
- $output->writeln("Found no shares with invalid share owner");
+ $output->writeln('Found no shares with invalid share owner');
}
return 0;
@@ -85,7 +87,7 @@ class RepairShareOwnership extends Command {
$brokenShares = $qb
->select('s.id', 'm.user_id', 's.uid_owner', 's.uid_initiator', 's.share_with', 's.file_target')
->from('share', 's')
- ->join('s', 'filecache', 'f', $qb->expr()->eq('s.item_source', $qb->expr()->castColumn('f.fileid', IQueryBuilder::PARAM_STR)))
+ ->join('s', 'filecache', 'f', $qb->expr()->eq($qb->expr()->castColumn('s.item_source', IQueryBuilder::PARAM_INT), 'f.fileid'))
->join('s', 'mounts', 'm', $qb->expr()->eq('f.storage', 'm.storage_id'))
->where($qb->expr()->neq('m.user_id', 's.uid_owner'))
->andWhere($qb->expr()->eq($qb->func()->concat($qb->expr()->literal('/'), 'm.user_id', $qb->expr()->literal('/')), 'm.mount_point'))
@@ -96,7 +98,7 @@ class RepairShareOwnership extends Command {
foreach ($brokenShares as $share) {
$found[] = [
- 'shareId' => (int) $share['id'],
+ 'shareId' => (int)$share['id'],
'fileTarget' => $share['file_target'],
'initiator' => $share['uid_initiator'],
'receiver' => $share['share_with'],
@@ -130,7 +132,7 @@ class RepairShareOwnership extends Command {
foreach ($brokenShares as $share) {
$found[] = [
- 'shareId' => (int) $share['id'],
+ 'shareId' => (int)$share['id'],
'fileTarget' => $share['file_target'],
'initiator' => $share['uid_initiator'],
'receiver' => $share['share_with'],