blob: b0dfec295e76381c16a7a354c771393909dca1fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<?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')));
}
}
}
|