mirror of
https://github.com/nextcloud/server.git
synced 2026-03-29 22:03:27 -04:00
refactor: Update repairs jobs
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
parent
3979c493f9
commit
fb3f9fe2de
42 changed files with 181 additions and 363 deletions
|
|
@ -16,27 +16,16 @@ class RemoveObjectProperties implements IRepairStep {
|
|||
private const ME_CARD_PROPERTY = '{http://calendarserver.org/ns/}me-card';
|
||||
private const CALENDAR_TRANSP_PROPERTY = '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp';
|
||||
|
||||
/**
|
||||
* RemoveObjectProperties constructor.
|
||||
*
|
||||
* @param IDBConnection $connection
|
||||
*/
|
||||
public function __construct(
|
||||
private IDBConnection $connection,
|
||||
private readonly IDBConnection $connection,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Remove invalid object properties';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$updated = $query->delete('properties')
|
||||
->where($query->expr()->in('propertyname', $query->createNamedParameter([self::RESOURCE_TYPE_PROPERTY, self::ME_CARD_PROPERTY, self::CALENDAR_TRANSP_PROPERTY], IQueryBuilder::PARAM_STR_ARRAY)))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Repair extends Command {
|
|||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('maintenance:repair')
|
||||
->setDescription('repair this installation')
|
||||
|
|
@ -81,20 +81,18 @@ class Repair extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$maintenanceMode = $this->config->getSystemValueBool('maintenance');
|
||||
$this->config->setSystemValue('maintenance', true);
|
||||
|
||||
$this->progress = new ProgressBar($output);
|
||||
$this->output = $output;
|
||||
$this->dispatcher->addListener(RepairStartEvent::class, [$this, 'handleRepairFeedBack']);
|
||||
$this->dispatcher->addListener(RepairAdvanceEvent::class, [$this, 'handleRepairFeedBack']);
|
||||
$this->dispatcher->addListener(RepairFinishEvent::class, [$this, 'handleRepairFeedBack']);
|
||||
$this->dispatcher->addListener(RepairStepEvent::class, [$this, 'handleRepairFeedBack']);
|
||||
$this->dispatcher->addListener(RepairInfoEvent::class, [$this, 'handleRepairFeedBack']);
|
||||
$this->dispatcher->addListener(RepairWarningEvent::class, [$this, 'handleRepairFeedBack']);
|
||||
$this->dispatcher->addListener(RepairErrorEvent::class, [$this, 'handleRepairFeedBack']);
|
||||
$this->dispatcher->addListener(RepairStartEvent::class, $this->handleRepairFeedBack(...));
|
||||
$this->dispatcher->addListener(RepairAdvanceEvent::class, $this->handleRepairFeedBack(...));
|
||||
$this->dispatcher->addListener(RepairFinishEvent::class, $this->handleRepairFeedBack(...));
|
||||
$this->dispatcher->addListener(RepairStepEvent::class, $this->handleRepairFeedBack(...));
|
||||
$this->dispatcher->addListener(RepairInfoEvent::class, $this->handleRepairFeedBack(...));
|
||||
$this->dispatcher->addListener(RepairWarningEvent::class, $this->handleRepairFeedBack(...));
|
||||
$this->dispatcher->addListener(RepairErrorEvent::class, $this->handleRepairFeedBack(...));
|
||||
|
||||
$this->repair->run();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ use OCP\Files\Search\ISearchQuery;
|
|||
use OCP\IUser;
|
||||
|
||||
class SearchQuery implements ISearchQuery {
|
||||
/**
|
||||
* @param ISearchOrder[] $order
|
||||
*/
|
||||
public function __construct(
|
||||
private ISearchOperator $searchOperation,
|
||||
private int $limit,
|
||||
|
|
@ -22,38 +25,26 @@ class SearchQuery implements ISearchQuery {
|
|||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ISearchOperator
|
||||
*/
|
||||
public function getSearchOperation() {
|
||||
public function getSearchOperation(): ISearchOperator {
|
||||
return $this->searchOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLimit() {
|
||||
public function getLimit(): int {
|
||||
return $this->limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOffset() {
|
||||
public function getOffset(): int {
|
||||
return $this->offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ISearchOrder[]
|
||||
*/
|
||||
public function getOrder() {
|
||||
public function getOrder(): array {
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?IUser
|
||||
*/
|
||||
public function getUser() {
|
||||
public function getUser(): ?IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ class FileProfilerStorage {
|
|||
*
|
||||
* Example : "file:/path/to/the/storage/folder"
|
||||
*
|
||||
* @param string $folder Folder where profiler data are stored.
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct(
|
||||
/** @var string $folder Folder where profiler data are stored. */
|
||||
private string $folder,
|
||||
) {
|
||||
if (!is_dir($this->folder) && @mkdir($this->folder, 0777, true) === false && !is_dir($this->folder)) {
|
||||
|
|
|
|||
|
|
@ -9,27 +9,17 @@ namespace OC\Remote;
|
|||
use OCP\Remote\ICredentials;
|
||||
|
||||
class Credentials implements ICredentials {
|
||||
/**
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
*/
|
||||
public function __construct(
|
||||
private $user,
|
||||
private $password,
|
||||
private string $user,
|
||||
private string $password,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername() {
|
||||
public function getUsername(): string {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword() {
|
||||
public function getPassword(): string {
|
||||
return $this->password;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
namespace OC;
|
||||
|
||||
use OC\DB\ConnectionAdapter;
|
||||
use OC\Repair\AddBruteForceCleanupJob;
|
||||
use OC\Repair\AddCleanupDeletedUsersBackgroundJob;
|
||||
use OC\Repair\AddCleanupUpdaterBackupsJob;
|
||||
|
|
@ -57,42 +56,32 @@ use OC\Repair\RepairDavShares;
|
|||
use OC\Repair\RepairInvalidShares;
|
||||
use OC\Repair\RepairLogoDimension;
|
||||
use OC\Repair\RepairMimeTypes;
|
||||
use OC\Template\JSCombiner;
|
||||
use OCA\DAV\Migration\DeleteSchedulingObjects;
|
||||
use OCA\DAV\Migration\RemoveObjectProperties;
|
||||
use OCA\Files_Sharing\Repair\CleanupShareTarget;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\Collaboration\Resources\IManager;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Files\AppData\IAppDataFactory;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
use OCP\Notification\IManager as INotificationManager;
|
||||
use OCP\Server;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
|
||||
class Repair implements IOutput {
|
||||
/** @var IRepairStep[] */
|
||||
/** @var list<IRepairStep> */
|
||||
private array $repairSteps = [];
|
||||
|
||||
private string $currentStep;
|
||||
|
||||
public function __construct(
|
||||
private IEventDispatcher $dispatcher,
|
||||
private LoggerInterface $logger,
|
||||
private readonly IEventDispatcher $dispatcher,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @param IRepairStep[] $repairSteps */
|
||||
/** @param list<IRepairStep> $repairSteps */
|
||||
public function setRepairSteps(array $repairSteps): void {
|
||||
$this->repairSteps = $repairSteps;
|
||||
}
|
||||
|
|
@ -100,7 +89,7 @@ class Repair implements IOutput {
|
|||
/**
|
||||
* Run a series of repair steps for common problems
|
||||
*/
|
||||
public function run() {
|
||||
public function run(): void {
|
||||
if (count($this->repairSteps) === 0) {
|
||||
$this->dispatcher->dispatchTyped(new RepairInfoEvent('No repair steps available'));
|
||||
|
||||
|
|
@ -124,19 +113,19 @@ class Repair implements IOutput {
|
|||
/**
|
||||
* Add repair step
|
||||
*
|
||||
* @param IRepairStep|string $repairStep repair step
|
||||
* @param IRepairStep|class-string<IRepairStep> $repairStep repair step
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addStep($repairStep) {
|
||||
public function addStep(IRepairStep|string $repairStep): void {
|
||||
if (is_string($repairStep)) {
|
||||
try {
|
||||
$s = Server::get($repairStep);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
if (class_exists($repairStep)) {
|
||||
try {
|
||||
// Last resort: hope there are no constructor arguments
|
||||
$s = new $repairStep();
|
||||
} catch (Throwable $inner) {
|
||||
} catch (Throwable) {
|
||||
// Well, it was worth a try
|
||||
throw new \Exception("Repair step '$repairStep' can't be instantiated: " . $e->getMessage(), 0, $e);
|
||||
}
|
||||
|
|
@ -159,35 +148,28 @@ class Repair implements IOutput {
|
|||
* Returns the default repair steps to be run on the
|
||||
* command line or after an upgrade.
|
||||
*
|
||||
* @return IRepairStep[]
|
||||
* @return list<IRepairStep>
|
||||
*/
|
||||
public static function getRepairSteps(): array {
|
||||
return [
|
||||
new Collation(Server::get(IConfig::class), Server::get(LoggerInterface::class), Server::get(IDBConnection::class), false),
|
||||
new CleanTags(Server::get(IDBConnection::class), Server::get(IUserManager::class)),
|
||||
new RepairInvalidShares(Server::get(IConfig::class), Server::get(IDBConnection::class)),
|
||||
new MoveUpdaterStepFile(Server::get(IConfig::class)),
|
||||
new MoveAvatars(
|
||||
Server::get(IJobList::class),
|
||||
Server::get(IConfig::class)
|
||||
),
|
||||
new CleanPreviews(
|
||||
Server::get(IJobList::class),
|
||||
Server::get(IUserManager::class),
|
||||
Server::get(IConfig::class)
|
||||
),
|
||||
Server::get(CleanTags::class),
|
||||
Server::get(RepairInvalidShares::class),
|
||||
Server::get(MoveUpdaterStepFile::class),
|
||||
Server::get(MoveAvatars::class),
|
||||
Server::get(CleanPreviews::class),
|
||||
Server::get(MigratePropertiesTable::class),
|
||||
Server::get(MigrateOauthTables::class),
|
||||
new UpdateLanguageCodes(Server::get(IDBConnection::class), Server::get(IConfig::class)),
|
||||
new AddLogRotateJob(Server::get(IJobList::class)),
|
||||
new ClearFrontendCaches(Server::get(ICacheFactory::class), Server::get(JSCombiner::class)),
|
||||
Server::get(UpdateLanguageCodes::class),
|
||||
Server::get(AddLogRotateJob::class),
|
||||
Server::get(ClearFrontendCaches::class),
|
||||
Server::get(ClearGeneratedAvatarCache::class),
|
||||
new AddPreviewBackgroundCleanupJob(Server::get(IJobList::class)),
|
||||
new AddCleanupUpdaterBackupsJob(Server::get(IJobList::class)),
|
||||
new CleanupCardDAVPhotoCache(Server::get(IConfig::class), Server::get(IAppDataFactory::class), Server::get(LoggerInterface::class)),
|
||||
new AddClenupLoginFlowV2BackgroundJob(Server::get(IJobList::class)),
|
||||
new RemoveLinkShares(Server::get(IDBConnection::class), Server::get(IConfig::class), Server::get(IGroupManager::class), Server::get(INotificationManager::class), Server::get(ITimeFactory::class)),
|
||||
new ClearCollectionsAccessCache(Server::get(IConfig::class), Server::get(IManager::class)),
|
||||
Server::get(AddPreviewBackgroundCleanupJob::class),
|
||||
Server::get(AddCleanupUpdaterBackupsJob::class),
|
||||
Server::get(CleanupCardDAVPhotoCache::class),
|
||||
Server::get(AddClenupLoginFlowV2BackgroundJob::class),
|
||||
Server::get(RemoveLinkShares::class),
|
||||
Server::get(ClearCollectionsAccessCache::class),
|
||||
Server::get(ResetGeneratedAvatarFlag::class),
|
||||
Server::get(EncryptionLegacyCipher::class),
|
||||
Server::get(EncryptionMigration::class),
|
||||
|
|
@ -214,17 +196,13 @@ class Repair implements IOutput {
|
|||
* Returns expensive repair steps to be run on the
|
||||
* command line with a special option.
|
||||
*
|
||||
* @return IRepairStep[]
|
||||
* @return list<IRepairStep>
|
||||
*/
|
||||
public static function getExpensiveRepairSteps() {
|
||||
public static function getExpensiveRepairSteps(): array {
|
||||
return [
|
||||
new OldGroupMembershipShares(Server::get(IDBConnection::class), Server::get(IGroupManager::class)),
|
||||
new RemoveBrokenProperties(Server::get(IDBConnection::class)),
|
||||
new RepairMimeTypes(
|
||||
Server::get(IConfig::class),
|
||||
Server::get(IAppConfig::class),
|
||||
Server::get(IDBConnection::class)
|
||||
),
|
||||
Server::get(OldGroupMembershipShares::class),
|
||||
Server::get(RemoveBrokenProperties::class),
|
||||
Server::get(RepairMimeTypes::class),
|
||||
Server::get(DeleteSchedulingObjects::class),
|
||||
Server::get(RemoveObjectProperties::class),
|
||||
Server::get(CleanupShareTarget::class),
|
||||
|
|
@ -235,19 +213,14 @@ class Repair implements IOutput {
|
|||
* Returns the repair steps to be run before an
|
||||
* upgrade.
|
||||
*
|
||||
* @return IRepairStep[]
|
||||
* @return list<IRepairStep>
|
||||
*/
|
||||
public static function getBeforeUpgradeRepairSteps() {
|
||||
/** @var ConnectionAdapter $connectionAdapter */
|
||||
$connectionAdapter = Server::get(ConnectionAdapter::class);
|
||||
$config = Server::get(IConfig::class);
|
||||
$steps = [
|
||||
new Collation(Server::get(IConfig::class), Server::get(LoggerInterface::class), $connectionAdapter, true),
|
||||
new SaveAccountsTableData($connectionAdapter, $config),
|
||||
new DropAccountTermsTable($connectionAdapter),
|
||||
public static function getBeforeUpgradeRepairSteps(): array {
|
||||
return [
|
||||
new Collation(Server::get(IConfig::class), Server::get(LoggerInterface::class), Server::get(IDBConnection::class), true),
|
||||
Server::get(SaveAccountsTableData::class),
|
||||
Server::get(DropAccountTermsTable::class),
|
||||
];
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
||||
public function debug(string $message): void {
|
||||
|
|
@ -256,7 +229,7 @@ class Repair implements IOutput {
|
|||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
public function info($message) {
|
||||
public function info($message): void {
|
||||
// for now just emit as we did in the past
|
||||
$this->dispatcher->dispatchTyped(new RepairInfoEvent($message));
|
||||
}
|
||||
|
|
@ -264,7 +237,7 @@ class Repair implements IOutput {
|
|||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
public function warning($message) {
|
||||
public function warning($message): void {
|
||||
// for now just emit as we did in the past
|
||||
$this->dispatcher->dispatchTyped(new RepairWarningEvent($message));
|
||||
}
|
||||
|
|
@ -272,7 +245,7 @@ class Repair implements IOutput {
|
|||
/**
|
||||
* @param int $max
|
||||
*/
|
||||
public function startProgress($max = 0) {
|
||||
public function startProgress($max = 0): void {
|
||||
// for now just emit as we did in the past
|
||||
$this->dispatcher->dispatchTyped(new RepairStartEvent($max, $this->currentStep));
|
||||
}
|
||||
|
|
@ -281,15 +254,12 @@ class Repair implements IOutput {
|
|||
* @param int $step number of step to advance
|
||||
* @param string $description
|
||||
*/
|
||||
public function advance($step = 1, $description = '') {
|
||||
public function advance($step = 1, $description = ''): void {
|
||||
// for now just emit as we did in the past
|
||||
$this->dispatcher->dispatchTyped(new RepairAdvanceEvent($step, $description));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max
|
||||
*/
|
||||
public function finishProgress() {
|
||||
public function finishProgress(): void {
|
||||
// for now just emit as we did in the past
|
||||
$this->dispatcher->dispatchTyped(new RepairFinishEvent());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ class AddBruteForceCleanupJob implements IRepairStep {
|
|||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Add job to cleanup the bruteforce entries';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$this->jobList->add(CleanupJob::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class AddCleanupDeletedUsersBackgroundJob implements IRepairStep {
|
|||
return 'Add cleanup-deleted-users background job';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$this->jobList->add(CleanupDeletedUsers::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ use OCP\Migration\IRepairStep;
|
|||
|
||||
class AddCleanupUpdaterBackupsJob implements IRepairStep {
|
||||
public function __construct(
|
||||
protected IJobList $jobList,
|
||||
protected readonly IJobList $jobList,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Queue a one-time job to cleanup old backups of the updater';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$this->jobList->add(BackgroundCleanupUpdaterBackupsJob::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ class AddMetadataGenerationJob implements IRepairStep {
|
|||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Queue a job to generate metadata';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$this->jobList->add(GenerateMetadataJob::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,20 @@ use OC\Core\BackgroundJobs\PreviewMigrationJob;
|
|||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
use Override;
|
||||
|
||||
class AddMovePreviewJob implements IRepairStep {
|
||||
public function __construct(
|
||||
private IJobList $jobList,
|
||||
private readonly IJobList $jobList,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Queue a job to move the preview';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
#[Override]
|
||||
public function run(IOutput $output): void {
|
||||
$this->jobList->add(PreviewMigrationJob::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use OCP\Migration\IRepairStep;
|
|||
|
||||
class AddRemoveOldTasksBackgroundJob implements IRepairStep {
|
||||
public function __construct(
|
||||
private IJobList $jobList,
|
||||
private readonly IJobList $jobList,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,29 +20,22 @@ use OCP\Migration\IRepairStep;
|
|||
*/
|
||||
class CleanTags implements IRepairStep {
|
||||
|
||||
protected $deletedTags = 0;
|
||||
protected int $deletedTags = 0;
|
||||
|
||||
/**
|
||||
* @param IDBConnection $connection
|
||||
* @param IUserManager $userManager
|
||||
*/
|
||||
public function __construct(
|
||||
protected IDBConnection $connection,
|
||||
protected IUserManager $userManager,
|
||||
protected readonly IDBConnection $connection,
|
||||
protected readonly IUserManager $userManager,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Clean tags and favorites';
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the configuration after running an update
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$this->deleteOrphanTags($output);
|
||||
$this->deleteOrphanFileEntries($output);
|
||||
$this->deleteOrphanTagEntries($output);
|
||||
|
|
@ -52,7 +45,7 @@ class CleanTags implements IRepairStep {
|
|||
/**
|
||||
* Delete tags for deleted users
|
||||
*/
|
||||
protected function deleteOrphanTags(IOutput $output) {
|
||||
protected function deleteOrphanTags(IOutput $output): void {
|
||||
$offset = 0;
|
||||
while ($this->checkTags($offset)) {
|
||||
$offset += 50;
|
||||
|
|
@ -61,7 +54,7 @@ class CleanTags implements IRepairStep {
|
|||
$output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags));
|
||||
}
|
||||
|
||||
protected function checkTags($offset) {
|
||||
protected function checkTags(int $offset): bool {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->select('uid')
|
||||
->from('vcategory')
|
||||
|
|
@ -98,7 +91,7 @@ class CleanTags implements IRepairStep {
|
|||
/**
|
||||
* Delete tag entries for deleted files
|
||||
*/
|
||||
protected function deleteOrphanFileEntries(IOutput $output) {
|
||||
protected function deleteOrphanFileEntries(IOutput $output): void {
|
||||
$this->deleteOrphanEntries(
|
||||
$output,
|
||||
'%d tags for delete files have been removed.',
|
||||
|
|
@ -110,7 +103,7 @@ class CleanTags implements IRepairStep {
|
|||
/**
|
||||
* Delete tag entries for deleted tags
|
||||
*/
|
||||
protected function deleteOrphanTagEntries(IOutput $output) {
|
||||
protected function deleteOrphanTagEntries(IOutput $output): void {
|
||||
$this->deleteOrphanEntries(
|
||||
$output,
|
||||
'%d tag entries for deleted tags have been removed.',
|
||||
|
|
@ -122,7 +115,7 @@ class CleanTags implements IRepairStep {
|
|||
/**
|
||||
* Delete tags that have no entries
|
||||
*/
|
||||
protected function deleteOrphanCategoryEntries(IOutput $output) {
|
||||
protected function deleteOrphanCategoryEntries(IOutput $output): void {
|
||||
$this->deleteOrphanEntries(
|
||||
$output,
|
||||
'%d tags with no entries have been removed.',
|
||||
|
|
@ -138,15 +131,10 @@ class CleanTags implements IRepairStep {
|
|||
* whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
|
||||
* is being deleted.
|
||||
*
|
||||
* @param string $repairInfo
|
||||
* @param string $deleteTable
|
||||
* @param string $deleteId
|
||||
* @param string $sourceTable
|
||||
* @param string $sourceId
|
||||
* @param string $sourceNullColumn If this column is null in the source table,
|
||||
* the entry is deleted in the $deleteTable
|
||||
*/
|
||||
protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
|
||||
protected function deleteOrphanEntries(IOutput $output, string $repairInfo, string $deleteTable, string $deleteId, string $sourceTable, string $sourceId, string $sourceNullColumn): void {
|
||||
$qb = $this->connection->getQueryBuilder();
|
||||
|
||||
$qb->select('d.' . $deleteId)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class CleanUpAbandonedApps implements IRepairStep {
|
|||
protected const ABANDONED_APPS = ['accessibility', 'files_videoplayer'];
|
||||
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private readonly IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ class ClearFrontendCaches implements IRepairStep {
|
|||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Clear frontend caches';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
try {
|
||||
$c = $this->cacheFactory->createDistributed('imagePath');
|
||||
$c->clear();
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ use OCP\Migration\IRepairStep;
|
|||
|
||||
class ClearGeneratedAvatarCache implements IRepairStep {
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
protected AvatarManager $avatarManager,
|
||||
private IJobList $jobList,
|
||||
private readonly IConfig $config,
|
||||
protected readonly AvatarManager $avatarManager,
|
||||
private readonly IJobList $jobList,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,25 +15,22 @@ use OCP\Migration\IRepairStep;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Collation implements IRepairStep {
|
||||
/**
|
||||
* @param bool $ignoreFailures
|
||||
*/
|
||||
public function __construct(
|
||||
protected IConfig $config,
|
||||
protected LoggerInterface $logger,
|
||||
protected IDBConnection $connection,
|
||||
protected $ignoreFailures,
|
||||
protected bool $ignoreFailures,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Repair MySQL collation';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix mime types
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) {
|
||||
$output->info('Not a mysql database -> nothing to do');
|
||||
return;
|
||||
|
|
@ -73,10 +70,9 @@ class Collation implements IRepairStep {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param IDBConnection $connection
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getAllNonUTF8BinTables(IDBConnection $connection) {
|
||||
protected function getAllNonUTF8BinTables(IDBConnection $connection): array {
|
||||
$dbName = $this->config->getSystemValueString('dbname');
|
||||
$characterSet = $this->config->getSystemValueBool('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8';
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class ConfigKeyMigration implements IRepairStep {
|
|||
return 'Migrate config keys';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$this->configManager->migrateConfigLexiconKeys();
|
||||
$this->configManager->updateLexiconEntries('core');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,19 +12,16 @@ use OCP\Migration\IOutput;
|
|||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class MoveUpdaterStepFile implements IRepairStep {
|
||||
/**
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(
|
||||
protected $config,
|
||||
protected IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Move .step file of updater to backup location';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$updateDir = $this->config->getSystemValue('updatedirectory', null) ?? $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
|
||||
$instanceId = $this->config->getSystemValueString('instanceid');
|
||||
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ use OCP\Migration\IRepairStep;
|
|||
|
||||
class AddLogRotateJob implements IRepairStep {
|
||||
public function __construct(
|
||||
private IJobList $jobList,
|
||||
private readonly IJobList $jobList,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Add log rotate job';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$this->jobList->add(Rotate::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use OCP\Migration\IRepairStep;
|
|||
|
||||
class AddPreviewBackgroundCleanupJob implements IRepairStep {
|
||||
public function __construct(
|
||||
private IJobList $jobList,
|
||||
private readonly IJobList $jobList,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,15 +9,14 @@ declare(strict_types=1);
|
|||
namespace OC\Repair\NC16;
|
||||
|
||||
use OC\Collaboration\Resources\Manager;
|
||||
use OCP\Collaboration\Resources\IManager;
|
||||
use OCP\IConfig;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class ClearCollectionsAccessCache implements IRepairStep {
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private IManager $manager,
|
||||
private readonly IConfig $config,
|
||||
private readonly Manager $manager,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -32,9 +31,7 @@ class ClearCollectionsAccessCache implements IRepairStep {
|
|||
|
||||
public function run(IOutput $output): void {
|
||||
if ($this->shouldRun()) {
|
||||
/** @var Manager $man */
|
||||
$man = $this->manager;
|
||||
$man->invalidateAccessCacheForAllCollections();
|
||||
$this->manager->invalidateAccessCacheForAllCollections();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ use OCP\Migration\IRepairStep;
|
|||
|
||||
class ResetGeneratedAvatarFlag implements IRepairStep {
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private IDBConnection $connection,
|
||||
private readonly IConfig $config,
|
||||
private readonly IDBConnection $connection,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ use OCP\Migration\IRepairStep;
|
|||
|
||||
class ShippedDashboardEnable implements IRepairStep {
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private readonly IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Remove old dashboard app config data';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$version = $this->config->getAppValue('dashboard', 'version', '7.0.0');
|
||||
if (version_compare($version, '7.0.0', '<')) {
|
||||
$this->config->deleteAppValues('dashboard');
|
||||
|
|
|
|||
|
|
@ -19,18 +19,18 @@ class AddCheckForUserCertificatesJob implements IRepairStep {
|
|||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Queue a one-time job to check for user uploaded certificates';
|
||||
}
|
||||
|
||||
private function shouldRun() {
|
||||
private function shouldRun(): bool {
|
||||
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
|
||||
|
||||
// was added to 21.0.0.2
|
||||
return version_compare($versionFromBeforeUpdate, '21.0.0.2', '<');
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
if ($this->shouldRun()) {
|
||||
$this->config->setAppValue('files_external', 'user_certificate_scan', 'not-run-yet');
|
||||
$this->jobList->add(CheckForUserCertificates::class);
|
||||
|
|
|
|||
|
|
@ -10,14 +10,12 @@ namespace OC\Repair\NC22;
|
|||
|
||||
use OC\Core\BackgroundJobs\LookupServerSendCheckBackgroundJob;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\IConfig;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class LookupServerSendCheck implements IRepairStep {
|
||||
public function __construct(
|
||||
private IJobList $jobList,
|
||||
private IConfig $config,
|
||||
private readonly IJobList $jobList,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use OCP\Migration\IRepairStep;
|
|||
|
||||
class AddTokenCleanupJob implements IRepairStep {
|
||||
public function __construct(
|
||||
private IJobList $jobList,
|
||||
private readonly IJobList $jobList,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ use OCP\Security\ISecureRandom;
|
|||
|
||||
class AddMissingSecretJob implements IRepairStep {
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private ISecureRandom $random,
|
||||
private readonly IConfig $config,
|
||||
private readonly ISecureRandom $random,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,26 +15,17 @@ use OCP\Share\IShare;
|
|||
|
||||
class OldGroupMembershipShares implements IRepairStep {
|
||||
/**
|
||||
* @var array [gid => [uid => (bool)]]
|
||||
* @var array<string, array<string, bool>> [gid => [uid => (bool)]]
|
||||
*/
|
||||
protected $memberships;
|
||||
protected array $memberships = [];
|
||||
|
||||
/**
|
||||
* @param IDBConnection $connection
|
||||
* @param IGroupManager $groupManager
|
||||
*/
|
||||
public function __construct(
|
||||
protected IDBConnection $connection,
|
||||
protected IGroupManager $groupManager,
|
||||
protected readonly IDBConnection $connection,
|
||||
protected readonly IGroupManager $groupManager,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the step's name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Remove shares of old group memberships';
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +35,7 @@ class OldGroupMembershipShares implements IRepairStep {
|
|||
*
|
||||
* @throws \Exception in case of failure
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$deletedEntries = 0;
|
||||
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
|
|
@ -75,12 +66,7 @@ class OldGroupMembershipShares implements IRepairStep {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $gid
|
||||
* @param string $uid
|
||||
* @return bool
|
||||
*/
|
||||
protected function isMember($gid, $uid) {
|
||||
protected function isMember(string $gid, string $uid): bool {
|
||||
if (isset($this->memberships[$gid][$uid])) {
|
||||
return $this->memberships[$gid][$uid];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,28 +14,18 @@ use OCP\Migration\IOutput;
|
|||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class CleanPreviews implements IRepairStep {
|
||||
/**
|
||||
* MoveAvatars constructor.
|
||||
*
|
||||
* @param IJobList $jobList
|
||||
* @param IUserManager $userManager
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(
|
||||
private IJobList $jobList,
|
||||
private IUserManager $userManager,
|
||||
private IConfig $config,
|
||||
private readonly IJobList $jobList,
|
||||
private readonly IUserManager $userManager,
|
||||
private readonly IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Add preview cleanup background jobs';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
if (!$this->config->getAppValue('core', 'previewsCleanedUp', false)) {
|
||||
$this->userManager->callForSeenUsers(function (IUser $user): void {
|
||||
$this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]);
|
||||
|
|
|
|||
|
|
@ -11,25 +11,16 @@ use OCP\Migration\IOutput;
|
|||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class DropAccountTermsTable implements IRepairStep {
|
||||
/**
|
||||
* @param IDBConnection $db
|
||||
*/
|
||||
public function __construct(
|
||||
protected IDBConnection $db,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Drop account terms table when migrating from ownCloud';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
if (!$this->db->tableExists('account_terms')) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,14 +34,11 @@ class MigrateOauthTables implements IRepairStep {
|
|||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Migrate oauth2_clients table to nextcloud schema';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$schema = new SchemaWrapper($this->db);
|
||||
if (!$schema->hasTable('oauth2_clients')) {
|
||||
$output->info('oauth2_clients table does not exist.');
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use OCP\Migration\IRepairStep;
|
|||
class MigratePropertiesTable implements IRepairStep {
|
||||
|
||||
public function __construct(
|
||||
private Connection $db,
|
||||
private readonly Connection $db,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,26 +12,17 @@ use OCP\Migration\IOutput;
|
|||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class MoveAvatars implements IRepairStep {
|
||||
/**
|
||||
* MoveAvatars constructor.
|
||||
*
|
||||
* @param IJobList $jobList
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(
|
||||
private IJobList $jobList,
|
||||
private IConfig $config,
|
||||
private readonly IJobList $jobList,
|
||||
private readonly IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Add move avatar background job';
|
||||
}
|
||||
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
// only run once
|
||||
if ($this->config->getAppValue('core', 'moveavatarsdone') === 'yes') {
|
||||
$output->info('Repair step already executed');
|
||||
|
|
|
|||
|
|
@ -20,29 +20,19 @@ use OCP\PreConditionNotMetException;
|
|||
class SaveAccountsTableData implements IRepairStep {
|
||||
public const BATCH_SIZE = 75;
|
||||
|
||||
protected $hasForeignKeyOnPersistentLocks = false;
|
||||
protected bool $hasForeignKeyOnPersistentLocks = false;
|
||||
|
||||
/**
|
||||
* @param IDBConnection $db
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(
|
||||
protected IDBConnection $db,
|
||||
protected IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Copy data from accounts table when migrating from ownCloud';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
if (!$this->shouldRun()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -71,10 +61,7 @@ class SaveAccountsTableData implements IRepairStep {
|
|||
$this->db->dropTable('accounts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldRun() {
|
||||
protected function shouldRun(): bool {
|
||||
$schema = $this->db->createSchema();
|
||||
$prefix = $this->config->getSystemValueString('dbtableprefix', 'oc_');
|
||||
|
||||
|
|
@ -102,10 +89,9 @@ class SaveAccountsTableData implements IRepairStep {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $offset
|
||||
* @return int Number of copied users
|
||||
*/
|
||||
protected function runStep($offset) {
|
||||
protected function runStep(int $offset): int {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('accounts')
|
||||
|
|
@ -127,9 +113,7 @@ class SaveAccountsTableData implements IRepairStep {
|
|||
while ($row = $result->fetch()) {
|
||||
try {
|
||||
$this->migrateUserInfo($update, $row);
|
||||
} catch (PreConditionNotMetException $e) {
|
||||
// Ignore and continue
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
} catch (PreConditionNotMetException|\UnexpectedValueException) {
|
||||
// Ignore and continue
|
||||
}
|
||||
$updatedUsers++;
|
||||
|
|
@ -140,12 +124,10 @@ class SaveAccountsTableData implements IRepairStep {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $update
|
||||
* @param array $userdata
|
||||
* @throws PreConditionNotMetException
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
protected function migrateUserInfo(IQueryBuilder $update, $userdata) {
|
||||
protected function migrateUserInfo(IQueryBuilder $update, array $userdata): void {
|
||||
$state = (int)$userdata['state'];
|
||||
if ($state === 3) {
|
||||
// Deleted user, ignore
|
||||
|
|
|
|||
|
|
@ -13,27 +13,17 @@ use OCP\Migration\IOutput;
|
|||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class UpdateLanguageCodes implements IRepairStep {
|
||||
/**
|
||||
* @param IDBConnection $connection
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(
|
||||
private IDBConnection $connection,
|
||||
private IConfig $config,
|
||||
private readonly IDBConnection $connection,
|
||||
private readonly IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Repair language codes';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
|
||||
|
||||
if (version_compare($versionFromBeforeUpdate, '12.0.0.13', '>')) {
|
||||
|
|
|
|||
|
|
@ -12,29 +12,21 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
use Override;
|
||||
|
||||
class RemoveBrokenProperties implements IRepairStep {
|
||||
/**
|
||||
* RemoveBrokenProperties constructor.
|
||||
*
|
||||
* @param IDBConnection $db
|
||||
*/
|
||||
public function __construct(
|
||||
private IDBConnection $db,
|
||||
private readonly IDBConnection $db,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getName() {
|
||||
#[Override]
|
||||
public function getName(): string {
|
||||
return 'Remove broken DAV object properties';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
#[Override]
|
||||
public function run(IOutput $output): void {
|
||||
// retrieve all object properties
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('id', 'propertyvalue')
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ use OCP\Notification\IManager;
|
|||
|
||||
class RemoveLinkShares implements IRepairStep {
|
||||
/** @var string[] */
|
||||
private $userToNotify = [];
|
||||
private array $userToNotify = [];
|
||||
|
||||
public function __construct(
|
||||
private IDBConnection $connection,
|
||||
private IConfig $config,
|
||||
private IGroupManager $groupManager,
|
||||
private IManager $notificationManager,
|
||||
private ITimeFactory $timeFactory,
|
||||
private readonly IDBConnection $connection,
|
||||
private readonly IConfig $config,
|
||||
private readonly IGroupManager $groupManager,
|
||||
private readonly IManager $notificationManager,
|
||||
private readonly ITimeFactory $timeFactory,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -53,8 +53,6 @@ class RemoveLinkShares implements IRepairStep {
|
|||
|
||||
/**
|
||||
* Delete the share
|
||||
*
|
||||
* @param int $id
|
||||
*/
|
||||
private function deleteShare(int $id): void {
|
||||
$qb = $this->connection->getQueryBuilder();
|
||||
|
|
@ -65,8 +63,6 @@ class RemoveLinkShares implements IRepairStep {
|
|||
|
||||
/**
|
||||
* Get the total of affected shares
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getTotal(): int {
|
||||
$subSubQuery = $this->connection->getQueryBuilder();
|
||||
|
|
@ -130,7 +126,7 @@ class RemoveLinkShares implements IRepairStep {
|
|||
/**
|
||||
* Process a single share
|
||||
*
|
||||
* @param array $data
|
||||
* @param array{id: int|string, uid_owner: string, uid_initiator: string} $data
|
||||
*/
|
||||
private function processShare(array $data): void {
|
||||
$id = $data['id'];
|
||||
|
|
@ -143,8 +139,6 @@ class RemoveLinkShares implements IRepairStep {
|
|||
|
||||
/**
|
||||
* Update list of users to notify
|
||||
*
|
||||
* @param string $uid
|
||||
*/
|
||||
private function addToNotify(string $uid): void {
|
||||
if (!isset($this->userToNotify[$uid])) {
|
||||
|
|
|
|||
|
|
@ -23,25 +23,21 @@ use function urlencode;
|
|||
class RepairDavShares implements IRepairStep {
|
||||
protected const GROUP_PRINCIPAL_PREFIX = 'principals/groups/';
|
||||
|
||||
/** @var bool */
|
||||
private $hintInvalidShares = false;
|
||||
private bool $hintInvalidShares = false;
|
||||
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private IDBConnection $dbc,
|
||||
private IGroupManager $groupManager,
|
||||
private LoggerInterface $logger,
|
||||
private readonly IConfig $config,
|
||||
private readonly IDBConnection $dbc,
|
||||
private readonly IGroupManager $groupManager,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Repair DAV shares';
|
||||
}
|
||||
|
||||
protected function repairUnencodedGroupShares() {
|
||||
protected function repairUnencodedGroupShares(): bool {
|
||||
$qb = $this->dbc->getQueryBuilder();
|
||||
$qb->select(['id', 'principaluri'])
|
||||
->from('dav_shares')
|
||||
|
|
@ -92,10 +88,7 @@ class RepairDavShares implements IRepairStep {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
public function run(IOutput $output): void {
|
||||
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
|
||||
if (version_compare($versionFromBeforeUpdate, '20.0.8', '<')
|
||||
&& $this->repairUnencodedGroupShares()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class RepairInvalidShares implements IRepairStep {
|
|||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return 'Repair invalid shares';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,14 +19,12 @@ use OCP\Migration\IRepairStep;
|
|||
class RepairMimeTypes implements IRepairStep {
|
||||
private bool $dryRun = false;
|
||||
private int $changeCount = 0;
|
||||
|
||||
/** @var int */
|
||||
protected int $folderMimeTypeId;
|
||||
|
||||
public function __construct(
|
||||
protected IConfig $config,
|
||||
protected IAppConfig $appConfig,
|
||||
protected IDBConnection $connection,
|
||||
protected readonly IConfig $config,
|
||||
protected readonly IAppConfig $appConfig,
|
||||
protected readonly IDBConnection $connection,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,9 @@ use Test\TestCase;
|
|||
|
||||
class TestCollationRepair extends Collation {
|
||||
/**
|
||||
* @param IDBConnection $connection
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAllNonUTF8BinTables(IDBConnection $connection) {
|
||||
public function getAllNonUTF8BinTables(IDBConnection $connection): array {
|
||||
return parent::getAllNonUTF8BinTables($connection);
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +48,6 @@ class RepairCollationTest extends TestCase {
|
|||
$this->connection = Server::get(ConnectionAdapter::class);
|
||||
if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) {
|
||||
$this->markTestSkipped('Test only relevant on MySql');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
|
|
|||
Loading…
Reference in a new issue