Skip to content

Commit 7d962ae

Browse files
come-ncbackportbot[bot]
authored andcommitted
chore(encryption): Remove unused attribute $uid in KeyManager::getFileKey
It’s a private API in the application, no need to keep an unused attribute. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 9ec147f commit 7d962ae

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

apps/encryption/lib/Command/DropLegacyFileKey.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function scanFolder(OutputInterface $output, string $folder): bool {
8585
$output->writeln('<error>' . $path . ' does not have a proper header</error>');
8686
} else {
8787
try {
88-
$legacyFileKey = $this->keyManager->getFileKey($path, null, true);
88+
$legacyFileKey = $this->keyManager->getFileKey($path, true);
8989
if ($legacyFileKey === '') {
9090
$output->writeln('Got an empty legacy filekey for ' . $path . ', continuing', OutputInterface::VERBOSITY_VERBOSE);
9191
continue;

apps/encryption/lib/Crypto/Encryption.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function begin($path, $user, $mode, array $header, array $accessList) {
127127
/* If useLegacyFileKey is not specified in header, auto-detect, to be safe */
128128
$useLegacyFileKey = (($header['useLegacyFileKey'] ?? '') == 'false' ? false : null);
129129

130-
$this->fileKey = $this->keyManager->getFileKey($this->path, null, $useLegacyFileKey, $this->session->decryptAllModeActivated());
130+
$this->fileKey = $this->keyManager->getFileKey($this->path, $useLegacyFileKey, $this->session->decryptAllModeActivated());
131131

132132
// always use the version from the original file, also part files
133133
// need to have a correct version number if they get moved over to the
@@ -335,7 +335,7 @@ public function update($path, $uid, array $accessList) {
335335
return false;
336336
}
337337

338-
$fileKey = $this->keyManager->getFileKey($path, null, null);
338+
$fileKey = $this->keyManager->getFileKey($path, null);
339339

340340
if (!empty($fileKey)) {
341341
$publicKeys = [];
@@ -438,7 +438,7 @@ public function getUnencryptedBlockSize($signed = false) {
438438
* @throws DecryptionFailedException
439439
*/
440440
public function isReadable($path, $uid) {
441-
$fileKey = $this->keyManager->getFileKey($path, $uid, null);
441+
$fileKey = $this->keyManager->getFileKey($path, null);
442442
if (empty($fileKey)) {
443443
$owner = $this->util->getOwner($path);
444444
if ($owner !== $uid) {

apps/encryption/lib/KeyManager.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,9 @@ public function getPrivateKey($userId) {
349349
}
350350

351351
/**
352-
* @param ?string $uid deprecated
353352
* @param ?bool $useLegacyFileKey null means try both
354353
*/
355-
public function getFileKey(string $path, ?string $uid, ?bool $useLegacyFileKey, bool $useDecryptAll = false): string {
354+
public function getFileKey(string $path, ?bool $useLegacyFileKey, bool $useDecryptAll = false): string {
356355
$publicAccess = ($this->keyUid === null);
357356
$encryptedFileKey = '';
358357
if ($useLegacyFileKey ?? true) {

apps/encryption/lib/Recovery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private function addRecoveryKeys(string $path): void {
159159
if ($item['type'] === 'dir') {
160160
$this->addRecoveryKeys($filePath . '/');
161161
} else {
162-
$fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID(), null);
162+
$fileKey = $this->keyManager->getFileKey($filePath, null);
163163
if (!empty($fileKey)) {
164164
$accessList = $this->file->getAccessList($filePath);
165165
$publicKeys = [];

apps/encryption/tests/Crypto/EncryptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function testBeginDecryptAll(): void {
232232
->willReturn(true);
233233
$this->keyManagerMock->expects($this->once())
234234
->method('getFileKey')
235-
->with($path, null, null, true)
235+
->with($path, null, true)
236236
->willReturn($fileKey);
237237

238238
$this->instance->begin($path, 'user', 'r', [], []);

apps/encryption/tests/KeyManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public function testGetFileKey(?string $uid, bool $isMasterKeyEnabled, string $p
417417
}
418418

419419
$this->assertSame($expected,
420-
$this->instance->getFileKey($path, null, null)
420+
$this->instance->getFileKey($path, null)
421421
);
422422
}
423423

0 commit comments

Comments
 (0)