0
0
mirror of https://github.com/nextcloud/server.git synced 2024-12-29 16:38:28 +00:00
nextcloud_server/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php
Andy Scherzinger dae7c159f7
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-24 13:11:22 +02:00

46 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Repair\NC18;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class ResetGeneratedAvatarFlag implements IRepairStep {
/** @var IConfig */
private $config;
/** @var IDBConnection */
private $connection;
public function __construct(IConfig $config,
IDBConnection $connection) {
$this->config = $config;
$this->connection = $connection;
}
public function getName(): string {
return 'Reset generated avatar flag';
}
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
return version_compare($versionFromBeforeUpdate, '18.0.0.5', '<=');
}
public function run(IOutput $output): void {
if ($this->shouldRun()) {
$query = $this->connection->getQueryBuilder();
$query->delete('preferences')
->where($query->expr()->eq('appid', $query->createNamedParameter('avatar')))
->andWhere($query->expr()->eq('configkey', $query->createNamedParameter('generated')));
}
}
}