From 8330f149b052ef586fdfd89703bf3d08e95812c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 8 Sep 2025 16:21:31 +0200 Subject: [PATCH] chore(encryption): Remove unused attribute $uid in KeyManager::getFileKey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s a private API in the application, no need to keep an unused attribute. Signed-off-by: Côme Chilliet --- apps/encryption/lib/Command/DropLegacyFileKey.php | 2 +- apps/encryption/lib/Crypto/Encryption.php | 6 +++--- apps/encryption/lib/KeyManager.php | 3 +-- apps/encryption/lib/Recovery.php | 2 +- apps/encryption/tests/Crypto/EncryptionTest.php | 2 +- apps/encryption/tests/KeyManagerTest.php | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/encryption/lib/Command/DropLegacyFileKey.php b/apps/encryption/lib/Command/DropLegacyFileKey.php index a9add1ad93b..e487a0aa013 100644 --- a/apps/encryption/lib/Command/DropLegacyFileKey.php +++ b/apps/encryption/lib/Command/DropLegacyFileKey.php @@ -85,7 +85,7 @@ class DropLegacyFileKey extends Command { $output->writeln('' . $path . ' does not have a proper header'); } else { try { - $legacyFileKey = $this->keyManager->getFileKey($path, null, true); + $legacyFileKey = $this->keyManager->getFileKey($path, true); if ($legacyFileKey === '') { $output->writeln('Got an empty legacy filekey for ' . $path . ', continuing', OutputInterface::VERBOSITY_VERBOSE); continue; diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php index 83f1b1182e3..daeb9859b41 100644 --- a/apps/encryption/lib/Crypto/Encryption.php +++ b/apps/encryption/lib/Crypto/Encryption.php @@ -127,7 +127,7 @@ class Encryption implements IEncryptionModule { /* If useLegacyFileKey is not specified in header, auto-detect, to be safe */ $useLegacyFileKey = (($header['useLegacyFileKey'] ?? '') == 'false' ? false : null); - $this->fileKey = $this->keyManager->getFileKey($this->path, null, $useLegacyFileKey, $this->session->decryptAllModeActivated()); + $this->fileKey = $this->keyManager->getFileKey($this->path, $useLegacyFileKey, $this->session->decryptAllModeActivated()); // always use the version from the original file, also part files // need to have a correct version number if they get moved over to the @@ -335,7 +335,7 @@ class Encryption implements IEncryptionModule { return false; } - $fileKey = $this->keyManager->getFileKey($path, null, null); + $fileKey = $this->keyManager->getFileKey($path, null); if (!empty($fileKey)) { $publicKeys = []; @@ -438,7 +438,7 @@ class Encryption implements IEncryptionModule { * @throws DecryptionFailedException */ public function isReadable($path, $uid) { - $fileKey = $this->keyManager->getFileKey($path, $uid, null); + $fileKey = $this->keyManager->getFileKey($path, null); if (empty($fileKey)) { $owner = $this->util->getOwner($path); if ($owner !== $uid) { diff --git a/apps/encryption/lib/KeyManager.php b/apps/encryption/lib/KeyManager.php index 5292c0b746c..b3e49c8124c 100644 --- a/apps/encryption/lib/KeyManager.php +++ b/apps/encryption/lib/KeyManager.php @@ -349,10 +349,9 @@ class KeyManager { } /** - * @param ?string $uid deprecated * @param ?bool $useLegacyFileKey null means try both */ - public function getFileKey(string $path, ?string $uid, ?bool $useLegacyFileKey, bool $useDecryptAll = false): string { + public function getFileKey(string $path, ?bool $useLegacyFileKey, bool $useDecryptAll = false): string { $publicAccess = ($this->keyUid === null); $encryptedFileKey = ''; if ($useLegacyFileKey ?? true) { diff --git a/apps/encryption/lib/Recovery.php b/apps/encryption/lib/Recovery.php index 9418e6fbea6..38d0c48ad89 100644 --- a/apps/encryption/lib/Recovery.php +++ b/apps/encryption/lib/Recovery.php @@ -159,7 +159,7 @@ class Recovery { if ($item['type'] === 'dir') { $this->addRecoveryKeys($filePath . '/'); } else { - $fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID(), null); + $fileKey = $this->keyManager->getFileKey($filePath, null); if (!empty($fileKey)) { $accessList = $this->file->getAccessList($filePath); $publicKeys = []; diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 5e09916b7a8..df9655cd2eb 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -232,7 +232,7 @@ class EncryptionTest extends TestCase { ->willReturn(true); $this->keyManagerMock->expects($this->once()) ->method('getFileKey') - ->with($path, null, null, true) + ->with($path, null, true) ->willReturn($fileKey); $this->instance->begin($path, 'user', 'r', [], []); diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index a6d895ce9f5..14d2a13e045 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -417,7 +417,7 @@ class KeyManagerTest extends TestCase { } $this->assertSame($expected, - $this->instance->getFileKey($path, null, null) + $this->instance->getFileKey($path, null) ); }