1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2017 Bjoern Schiessle <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @license GNU AGPL version 3 or any later version |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as |
9
|
|
|
* published by the Free Software Foundation, either version 3 of the |
10
|
|
|
* License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
namespace OCA\Encryption\Migration; |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
use OCP\IConfig; |
27
|
|
|
use OCP\Migration\IOutput; |
28
|
|
|
use OCP\Migration\IRepairStep; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Class SetPasswordColumn |
32
|
|
|
* |
33
|
|
|
* @package OCA\Files_Sharing\Migration |
34
|
|
|
*/ |
35
|
|
|
class SetMasterKeyStatus implements IRepairStep { |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** @var IConfig */ |
39
|
|
|
private $config; |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
public function __construct(IConfig $config) { |
43
|
|
|
$this->config = $config; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Returns the step's name |
48
|
|
|
* |
49
|
|
|
* @return string |
50
|
|
|
* @since 9.1.0 |
51
|
|
|
*/ |
52
|
|
|
public function getName() { |
53
|
|
|
return 'Write default encryption module configuration to the database'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param IOutput $output |
58
|
|
|
*/ |
59
|
|
|
public function run(IOutput $output) { |
60
|
|
|
if (!$this->shouldRun()) { |
61
|
|
|
return; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
// if no config for the master key is set we set it explicitly to '0' in |
65
|
|
|
// order not to break old installations because the default changed to '1'. |
66
|
|
|
$configAlreadySet = $this->config->getAppValue('encryption', 'useMasterKey', false); |
|
|
|
|
67
|
|
|
if ($configAlreadySet === false) { |
68
|
|
|
$this->config->setAppValue('encryption', 'useMasterKey', '0'); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
protected function shouldRun() { |
73
|
|
|
$appVersion = $this->config->getAppValue('encryption', 'installed_version', '0.0.0'); |
74
|
|
|
return version_compare($appVersion, '2.0.0', '<'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: