diff options
Diffstat (limited to 'lib')
31 files changed, 216 insertions, 120 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index a365ae15c67..29910544895 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -26,6 +26,7 @@ return array( 'OCP\\AppFramework\\Controller' => $baseDir . '/lib/public/AppFramework/Controller.php', 'OCP\\AppFramework\\Db\\DoesNotExistException' => $baseDir . '/lib/public/AppFramework/Db/DoesNotExistException.php', 'OCP\\AppFramework\\Db\\Entity' => $baseDir . '/lib/public/AppFramework/Db/Entity.php', + 'OCP\\AppFramework\\Db\\IMapperException' => $baseDir . '/lib/public/AppFramework/Db/IMapperException.php', 'OCP\\AppFramework\\Db\\Mapper' => $baseDir . '/lib/public/AppFramework/Db/Mapper.php', 'OCP\\AppFramework\\Db\\MultipleObjectsReturnedException' => $baseDir . '/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php', 'OCP\\AppFramework\\Db\\QBMapper' => $baseDir . '/lib/public/AppFramework/Db/QBMapper.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index a85163c6dde..d476460c827 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -56,6 +56,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\AppFramework\\Controller' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Controller.php', 'OCP\\AppFramework\\Db\\DoesNotExistException' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Db/DoesNotExistException.php', 'OCP\\AppFramework\\Db\\Entity' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Db/Entity.php', + 'OCP\\AppFramework\\Db\\IMapperException' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Db/IMapperException.php', 'OCP\\AppFramework\\Db\\Mapper' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Db/Mapper.php', 'OCP\\AppFramework\\Db\\MultipleObjectsReturnedException' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php', 'OCP\\AppFramework\\Db\\QBMapper' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Db/QBMapper.php', diff --git a/lib/l10n/bg.js b/lib/l10n/bg.js index 23212a61785..ad8033f996b 100644 --- a/lib/l10n/bg.js +++ b/lib/l10n/bg.js @@ -19,10 +19,13 @@ OC.L10N.register( "Unknown filetype" : "Непознат тип файл", "Invalid image" : "Невалидно изображение.", "today" : "днес", + "tomorrow" : "утре", "yesterday" : "вчера", "_%n day ago_::_%n days ago_" : ["преди %n ден","преди %n дни"], + "next month" : "следващия месец", "last month" : "миналия месец", "_%n month ago_::_%n months ago_" : ["преди %n месец","преди %n месеца"], + "next year" : "следващата година", "last year" : "миналата година", "_%n year ago_::_%n years ago_" : ["преди %n година","преди %n години"], "_%n hour ago_::_%n hours ago_" : ["преди %n час","преди %n часа"], @@ -55,6 +58,7 @@ OC.L10N.register( "Set an admin username." : "Задайте потребителско име за администратор.", "Set an admin password." : "Задай парола за администратор.", "Can't create or write into the data directory %s" : "Неуспешно създаване или записване в \"data\" папката %s", + "Invalid Federated Cloud ID" : "Невалиден Federated Cloud ID", "Sharing %s failed, because the backend does not allow shares from type %i" : "Неуспешно споделяне на %s , защото сървъра не позволява споделяне от тип $i.", "Sharing %s failed, because the file does not exist" : "Неуспешно споделяне на %s, защото файлът не съществува.", "You are not allowed to share %s" : "Не ти е разрешено да споделяш %s.", @@ -68,6 +72,8 @@ OC.L10N.register( "Sharing %s failed, because resharing is not allowed" : "Неуспешно споделяне на %s, защото повторното споделяне е забранено", "Sharing %s failed, because the file could not be found in the file cache" : "Неуспешно споделяне на %s, защото файлът не може да бъде намерен в кеша.", "Can’t set expiration date more than %s days in the future" : "Неуспешно задаване на срок на валидност повече от %s дни в бъдещето", + "%1$s shared »%2$s« with you" : "%1$s сподели »%2$s« с вас", + "%1$s shared »%2$s« with you." : "%1$s сподели »%2$s« с вас.", "Could not find category \"%s\"" : "Невъзможно откриване на категорията \"%s\".", "Sunday" : "неделя", "Monday" : "понеделник", @@ -85,6 +91,7 @@ OC.L10N.register( "Sat." : "съб", "Su" : "нд", "Mo" : "пн", + "Tu" : "вт", "We" : "ср", "Th" : "чт", "Fr" : "пт", @@ -118,10 +125,11 @@ OC.L10N.register( "Username contains whitespace at the beginning or at the end" : "Потребителското име започва или завършва с интервал.", "A valid password must be provided" : "Трябва да въведете валидна парола.", "The username is already being used" : "Потребителското име е вече заето.", + "User disabled" : "Потребителят е деактивиран", "a safe home for all your data" : "безопасен дом за всички ваши данни", "Can't read file" : "Файлът не може да бъде прочетен", "Application is not enabled" : "Приложението не е включено", - "Authentication error" : "Проблем с идентификацията", + "Authentication error" : "Грешка при удостоверяването", "Token expired. Please reload page." : "Изтекла сесия. Моля, презареди страницата.", "No database drivers (sqlite, mysql, or postgresql) installed." : "Липсват инсталирани драйвери за бази данни(sqlite, mysql или postgresql).", "Cannot write into \"config\" directory" : "Неуспешен опит за запис в \"config\" папката.", @@ -141,6 +149,8 @@ OC.L10N.register( "Library %s with a version lower than %s is required - available version %s." : "Необходима е библиотеката %s с версия по-ниска от %s - налична версия %s. ", "APCu" : "APCu", "Redis" : "Redis", + "Encryption" : "Криптиране", + "Sync clients" : "Клиенти за синхронизиране", "Sharing %s failed, because the user %s does not exist" : "Неуспешно споделяне на %s, защото потребител %s не съществува.", "Sharing %s failed, because the user %s is not a member of any groups that %s is a member of" : "Неуспешно споделяне на %s, защото %s не е член никоя от групите, в които е %s.", "Sharing %s failed, because this item is already shared with %s" : "Неуспешно споделяне на %s, защото това съдържание е вече споделено с %s.", @@ -151,6 +161,7 @@ OC.L10N.register( "Sharing %s failed, because the permissions exceed permissions granted to %s" : "Неуспешно споделяне на %s, защото промените надвишават правата на достъп дадени на %s.", "Sharing %s failed, because the sharing backend for %s could not find its source" : "Неуспешно споделяне на %s, защото не е открит първоизточникът на %s, за да бъде споделяне по сървъра.", "%s shared »%s« with you" : "%s сподели »%s« с вас", + "%s shared »%s« with you." : "%s сподели »%s« с вас.", "%s via %s" : "%s чрез %s" }, "nplurals=2; plural=(n != 1);"); diff --git a/lib/l10n/bg.json b/lib/l10n/bg.json index 0f5e7a28663..81c2298c086 100644 --- a/lib/l10n/bg.json +++ b/lib/l10n/bg.json @@ -17,10 +17,13 @@ "Unknown filetype" : "Непознат тип файл", "Invalid image" : "Невалидно изображение.", "today" : "днес", + "tomorrow" : "утре", "yesterday" : "вчера", "_%n day ago_::_%n days ago_" : ["преди %n ден","преди %n дни"], + "next month" : "следващия месец", "last month" : "миналия месец", "_%n month ago_::_%n months ago_" : ["преди %n месец","преди %n месеца"], + "next year" : "следващата година", "last year" : "миналата година", "_%n year ago_::_%n years ago_" : ["преди %n година","преди %n години"], "_%n hour ago_::_%n hours ago_" : ["преди %n час","преди %n часа"], @@ -53,6 +56,7 @@ "Set an admin username." : "Задайте потребителско име за администратор.", "Set an admin password." : "Задай парола за администратор.", "Can't create or write into the data directory %s" : "Неуспешно създаване или записване в \"data\" папката %s", + "Invalid Federated Cloud ID" : "Невалиден Federated Cloud ID", "Sharing %s failed, because the backend does not allow shares from type %i" : "Неуспешно споделяне на %s , защото сървъра не позволява споделяне от тип $i.", "Sharing %s failed, because the file does not exist" : "Неуспешно споделяне на %s, защото файлът не съществува.", "You are not allowed to share %s" : "Не ти е разрешено да споделяш %s.", @@ -66,6 +70,8 @@ "Sharing %s failed, because resharing is not allowed" : "Неуспешно споделяне на %s, защото повторното споделяне е забранено", "Sharing %s failed, because the file could not be found in the file cache" : "Неуспешно споделяне на %s, защото файлът не може да бъде намерен в кеша.", "Can’t set expiration date more than %s days in the future" : "Неуспешно задаване на срок на валидност повече от %s дни в бъдещето", + "%1$s shared »%2$s« with you" : "%1$s сподели »%2$s« с вас", + "%1$s shared »%2$s« with you." : "%1$s сподели »%2$s« с вас.", "Could not find category \"%s\"" : "Невъзможно откриване на категорията \"%s\".", "Sunday" : "неделя", "Monday" : "понеделник", @@ -83,6 +89,7 @@ "Sat." : "съб", "Su" : "нд", "Mo" : "пн", + "Tu" : "вт", "We" : "ср", "Th" : "чт", "Fr" : "пт", @@ -116,10 +123,11 @@ "Username contains whitespace at the beginning or at the end" : "Потребителското име започва или завършва с интервал.", "A valid password must be provided" : "Трябва да въведете валидна парола.", "The username is already being used" : "Потребителското име е вече заето.", + "User disabled" : "Потребителят е деактивиран", "a safe home for all your data" : "безопасен дом за всички ваши данни", "Can't read file" : "Файлът не може да бъде прочетен", "Application is not enabled" : "Приложението не е включено", - "Authentication error" : "Проблем с идентификацията", + "Authentication error" : "Грешка при удостоверяването", "Token expired. Please reload page." : "Изтекла сесия. Моля, презареди страницата.", "No database drivers (sqlite, mysql, or postgresql) installed." : "Липсват инсталирани драйвери за бази данни(sqlite, mysql или postgresql).", "Cannot write into \"config\" directory" : "Неуспешен опит за запис в \"config\" папката.", @@ -139,6 +147,8 @@ "Library %s with a version lower than %s is required - available version %s." : "Необходима е библиотеката %s с версия по-ниска от %s - налична версия %s. ", "APCu" : "APCu", "Redis" : "Redis", + "Encryption" : "Криптиране", + "Sync clients" : "Клиенти за синхронизиране", "Sharing %s failed, because the user %s does not exist" : "Неуспешно споделяне на %s, защото потребител %s не съществува.", "Sharing %s failed, because the user %s is not a member of any groups that %s is a member of" : "Неуспешно споделяне на %s, защото %s не е член никоя от групите, в които е %s.", "Sharing %s failed, because this item is already shared with %s" : "Неуспешно споделяне на %s, защото това съдържание е вече споделено с %s.", @@ -149,6 +159,7 @@ "Sharing %s failed, because the permissions exceed permissions granted to %s" : "Неуспешно споделяне на %s, защото промените надвишават правата на достъп дадени на %s.", "Sharing %s failed, because the sharing backend for %s could not find its source" : "Неуспешно споделяне на %s, защото не е открит първоизточникът на %s, за да бъде споделяне по сървъра.", "%s shared »%s« with you" : "%s сподели »%s« с вас", + "%s shared »%s« with you." : "%s сподели »%s« с вас.", "%s via %s" : "%s чрез %s" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/lib/l10n/fr.js b/lib/l10n/fr.js index 0625fadf008..4154f32bdaa 100644 --- a/lib/l10n/fr.js +++ b/lib/l10n/fr.js @@ -195,7 +195,7 @@ OC.L10N.register( "User disabled" : "Utilisateur désactivé", "Login canceled by app" : "L'authentification a été annulé par l'application", "App \"%1$s\" cannot be installed because the following dependencies are not fulfilled: %2$s" : "L'application \"%1$s\" ne peut pas être installée à cause des dépendances suivantes non satisfaites : %2$s", - "a safe home for all your data" : "un endroit sûr pour toutes vos données", + "a safe home for all your data" : "un lieu sûr pour toutes vos données", "File is currently busy, please try again later" : "Le fichier est actuellement utilisé, veuillez réessayer plus tard", "Can't read file" : "Impossible de lire le fichier", "Application is not enabled" : "L'application n'est pas activée", diff --git a/lib/l10n/fr.json b/lib/l10n/fr.json index 5b67c88fd35..00503087eae 100644 --- a/lib/l10n/fr.json +++ b/lib/l10n/fr.json @@ -193,7 +193,7 @@ "User disabled" : "Utilisateur désactivé", "Login canceled by app" : "L'authentification a été annulé par l'application", "App \"%1$s\" cannot be installed because the following dependencies are not fulfilled: %2$s" : "L'application \"%1$s\" ne peut pas être installée à cause des dépendances suivantes non satisfaites : %2$s", - "a safe home for all your data" : "un endroit sûr pour toutes vos données", + "a safe home for all your data" : "un lieu sûr pour toutes vos données", "File is currently busy, please try again later" : "Le fichier est actuellement utilisé, veuillez réessayer plus tard", "Can't read file" : "Impossible de lire le fichier", "Application is not enabled" : "L'application n'est pas activée", diff --git a/lib/l10n/ja.js b/lib/l10n/ja.js index 40b2de0688f..62d617bf302 100644 --- a/lib/l10n/ja.js +++ b/lib/l10n/ja.js @@ -95,7 +95,7 @@ OC.L10N.register( "Set an admin username." : "管理者のユーザー名を設定", "Set an admin password." : "管理者のパスワードを設定", "Can't create or write into the data directory %s" : "%s データディレクトリに作成、書き込みができません", - "Invalid Federated Cloud ID" : "無効な統合されたクラウドID", + "Invalid Federated Cloud ID" : "無効なクラウド共有ID", "Sharing %s failed, because the backend does not allow shares from type %i" : "%s を共有できませんでした。%i タイプからの共有は許可されていません。", "Sharing %s failed, because the file does not exist" : "%s を共有できませんでした。そのファイルは存在しません。", "You are not allowed to share %s" : "%s を共有することを許可されていません。", diff --git a/lib/l10n/ja.json b/lib/l10n/ja.json index ff48d5ac925..c210002a370 100644 --- a/lib/l10n/ja.json +++ b/lib/l10n/ja.json @@ -93,7 +93,7 @@ "Set an admin username." : "管理者のユーザー名を設定", "Set an admin password." : "管理者のパスワードを設定", "Can't create or write into the data directory %s" : "%s データディレクトリに作成、書き込みができません", - "Invalid Federated Cloud ID" : "無効な統合されたクラウドID", + "Invalid Federated Cloud ID" : "無効なクラウド共有ID", "Sharing %s failed, because the backend does not allow shares from type %i" : "%s を共有できませんでした。%i タイプからの共有は許可されていません。", "Sharing %s failed, because the file does not exist" : "%s を共有できませんでした。そのファイルは存在しません。", "You are not allowed to share %s" : "%s を共有することを許可されていません。", diff --git a/lib/l10n/sv.js b/lib/l10n/sv.js index 2912e855ef3..3d5b8ec3c9a 100644 --- a/lib/l10n/sv.js +++ b/lib/l10n/sv.js @@ -133,7 +133,7 @@ OC.L10N.register( "Can’t set expiration date more than %s days in the future" : "Kan inte sätta utgångsdatum mer än %s dagar framåt", "%1$s shared »%2$s« with you" : "%1$s delade »%2$s« med dig", "%1$s shared »%2$s« with you." : "%1$s delade »%2$s« med dig.", - "Click the button below to open it." : "Klicka knappen nedan för att öppna det.", + "Click the button below to open it." : "Klicka på knappen nedan för att öppna det.", "The requested share does not exist anymore" : "Den begärda delningen finns inte mer", "Could not find category \"%s\"" : "Kunde inte hitta kategorin \"%s\"", "Sunday" : "Söndag", diff --git a/lib/l10n/sv.json b/lib/l10n/sv.json index da2a846c213..5cf82b4b56b 100644 --- a/lib/l10n/sv.json +++ b/lib/l10n/sv.json @@ -131,7 +131,7 @@ "Can’t set expiration date more than %s days in the future" : "Kan inte sätta utgångsdatum mer än %s dagar framåt", "%1$s shared »%2$s« with you" : "%1$s delade »%2$s« med dig", "%1$s shared »%2$s« with you." : "%1$s delade »%2$s« med dig.", - "Click the button below to open it." : "Klicka knappen nedan för att öppna det.", + "Click the button below to open it." : "Klicka på knappen nedan för att öppna det.", "The requested share does not exist anymore" : "Den begärda delningen finns inte mer", "Could not find category \"%s\"" : "Kunde inte hitta kategorin \"%s\"", "Sunday" : "Söndag", diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index 9f596ac4568..fa9f11a65ab 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -295,6 +295,10 @@ class PublicKeyTokenProvider implements IProvider { // Generate new key $res = openssl_pkey_new($config); + if ($res === false) { + $this->logOpensslError(); + } + openssl_pkey_export($res, $privateKey); // Extract the public key from $res to $pubKey @@ -343,5 +347,11 @@ class PublicKeyTokenProvider implements IProvider { } } - + private function logOpensslError() { + $errors = []; + while ($error = openssl_error_string()) { + $errors[] = $error; + } + $this->logger->critical('Something is wrong with your openssl setup: ' . implode(', ', $errors)); + } } diff --git a/lib/private/Files/AppData/AppData.php b/lib/private/Files/AppData/AppData.php index e25bf450446..3d098ad98ca 100644 --- a/lib/private/Files/AppData/AppData.php +++ b/lib/private/Files/AppData/AppData.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace OC\Files\AppData; +use OC\Cache\CappedMemoryCache; use OC\Files\SimpleFS\SimpleFolder; use OCP\Files\IAppData; use OCP\Files\IRootFolder; @@ -48,6 +49,9 @@ class AppData implements IAppData { /** @var Folder */ private $folder; + /** @var (ISimpleFolder|NotFoundException)[]|CappedMemoryCache */ + private $folders; + /** * AppData constructor. * @@ -62,6 +66,32 @@ class AppData implements IAppData { $this->rootFolder = $rootFolder; $this->config = $systemConfig; $this->appId = $appId; + $this->folders = new CappedMemoryCache(); + } + + private function getAppDataFolderName() { + $instanceId = $this->config->getValue('instanceid', null); + if ($instanceId === null) { + throw new \RuntimeException('no instance id!'); + } + + return 'appdata_' . $instanceId; + } + + private function getAppDataRootFolder(): Folder { + $name = $this->getAppDataFolderName(); + + try { + /** @var Folder $node */ + $node = $this->rootFolder->get($name); + return $node; + } catch (NotFoundException $e) { + try { + return $this->rootFolder->newFolder($name); + } catch (NotPermittedException $e) { + throw new \RuntimeException('Could not get appdata folder'); + } + } } /** @@ -70,56 +100,64 @@ class AppData implements IAppData { */ private function getAppDataFolder(): Folder { if ($this->folder === null) { - $instanceId = $this->config->getValue('instanceid', null); - if ($instanceId === null) { - throw new \RuntimeException('no instance id!'); - } - - $name = 'appdata_' . $instanceId; + $name = $this->getAppDataFolderName(); try { - $appDataFolder = $this->rootFolder->get($name); + $this->folder = $this->rootFolder->get($name . '/' . $this->appId); } catch (NotFoundException $e) { - try { - $appDataFolder = $this->rootFolder->newFolder($name); - } catch (NotPermittedException $e) { - throw new \RuntimeException('Could not get appdata folder'); - } - } + $appDataRootFolder = $this->getAppDataRootFolder(); - try { - $appDataFolder = $appDataFolder->get($this->appId); - } catch (NotFoundException $e) { try { - $appDataFolder = $appDataFolder->newFolder($this->appId); - } catch (NotPermittedException $e) { - throw new \RuntimeException('Could not get appdata folder for ' . $this->appId); + $this->folder = $appDataRootFolder->get($this->appId); + } catch (NotFoundException $e) { + try { + $this->folder = $appDataRootFolder->newFolder($this->appId); + } catch (NotPermittedException $e) { + throw new \RuntimeException('Could not get appdata folder for ' . $this->appId); + } } } - - $this->folder = $appDataFolder; } return $this->folder; } public function getFolder(string $name): ISimpleFolder { - $node = $this->getAppDataFolder()->get($name); + $key = $this->appId . '/' . $name; + if ($cachedFolder = $this->folders->get($key)) { + if ($cachedFolder instanceof \Exception) { + throw $cachedFolder; + } else { + return $cachedFolder; + } + } + try { + $path = $this->getAppDataFolderName() . '/' . $this->appId . '/' . $name; + $node = $this->rootFolder->get($path); + } catch (NotFoundException $e) { + $this->folders->set($key, $e); + throw $e; + } /** @var Folder $node */ - return new SimpleFolder($node); + $folder = new SimpleFolder($node); + $this->folders->set($key, $folder); + return $folder; } public function newFolder(string $name): ISimpleFolder { + $key = $this->appId . '/' . $name; $folder = $this->getAppDataFolder()->newFolder($name); - return new SimpleFolder($folder); + $simpleFolder = new SimpleFolder($folder); + $this->folders->set($key, $simpleFolder); + return $simpleFolder; } public function getDirectoryListing(): array { $listing = $this->getAppDataFolder()->getDirectoryListing(); - $fileListing = array_map(function(Node $folder) { + $fileListing = array_map(function (Node $folder) { if ($folder instanceof Folder) { return new SimpleFolder($folder); } diff --git a/lib/private/Files/AppData/Factory.php b/lib/private/Files/AppData/Factory.php index fba2232db06..5c7d554ba5b 100644 --- a/lib/private/Files/AppData/Factory.php +++ b/lib/private/Files/AppData/Factory.php @@ -34,6 +34,8 @@ class Factory { /** @var SystemConfig */ private $config; + private $folders = []; + public function __construct(IRootFolder $rootFolder, SystemConfig $systemConfig) { @@ -46,6 +48,9 @@ class Factory { * @return AppData */ public function get(string $appId): AppData { - return new AppData($this->rootFolder, $this->config, $appId); + if (!isset($this->folders[$appId])) { + $this->folders[$appId] = new AppData($this->rootFolder, $this->config, $appId); + } + return $this->folders[$appId]; } } diff --git a/lib/private/Files/Cache/Propagator.php b/lib/private/Files/Cache/Propagator.php index ae51b2e52d8..989a4d0c7d5 100644 --- a/lib/private/Files/Cache/Propagator.php +++ b/lib/private/Files/Cache/Propagator.php @@ -46,12 +46,14 @@ class Propagator implements IPropagator { private $connection; /** - * @param \OC\Files\Storage\Storage $storage - * @param IDBConnection $connection + * @var array */ - public function __construct(\OC\Files\Storage\Storage $storage, IDBConnection $connection) { + private $ignore = []; + + public function __construct(\OC\Files\Storage\Storage $storage, IDBConnection $connection, array $ignore = []) { $this->storage = $storage; $this->connection = $connection; + $this->ignore = $ignore; } @@ -62,6 +64,13 @@ class Propagator implements IPropagator { * @suppress SqlInjectionChecker */ public function propagateChange($internalPath, $time, $sizeDifference = 0) { + // Do not propogate changes in ignored paths + foreach ($this->ignore as $ignore) { + if (strpos($internalPath, $ignore) === 0) { + return; + } + } + $storageId = (int)$this->storage->getStorageCache()->getNumericId(); $parents = $this->getParents($internalPath); @@ -97,9 +106,9 @@ class Propagator implements IPropagator { ->where($builder->expr()->eq('storage', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))) ->andWhere($builder->expr()->in('path_hash', $hashParams)) ->andWhere($builder->expr()->gt('size', $builder->expr()->literal(-1, IQueryBuilder::PARAM_INT))); - } - $builder->execute(); + $builder->execute(); + } } protected function getParents($path) { diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 72fe3a79792..657a8ba611a 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -368,7 +368,8 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { $storage = $this; } if (!isset($storage->propagator)) { - $storage->propagator = new Propagator($storage, \OC::$server->getDatabaseConnection()); + $config = \OC::$server->getSystemConfig(); + $storage->propagator = new Propagator($storage, \OC::$server->getDatabaseConnection(), ['appdata_' . $config->getValue('instanceid')]); } return $storage->propagator; } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 19e38717803..21df67cf557 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1157,7 +1157,7 @@ class View { if ($result && in_array('delete', $hooks) and $result) { $this->removeUpdate($storage, $internalPath); } - if ($result && in_array('write', $hooks) and $operation !== 'fopen') { + if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') { $this->writeUpdate($storage, $internalPath); } if ($result && in_array('touch', $hooks)) { diff --git a/lib/private/Repair.php b/lib/private/Repair.php index da825c9a7ad..8bb3d3327a6 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -147,7 +147,7 @@ class Repair implements IOutput { new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()), new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), new RepairPendingCronJobs(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()), - new SetVcardDatabaseUID(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()) + new SetVcardDatabaseUID(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getLogger()) ]; } diff --git a/lib/private/Repair/NC15/SetVcardDatabaseUID.php b/lib/private/Repair/NC15/SetVcardDatabaseUID.php index 210fc0a862c..cefb1c18111 100644 --- a/lib/private/Repair/NC15/SetVcardDatabaseUID.php +++ b/lib/private/Repair/NC15/SetVcardDatabaseUID.php @@ -25,9 +25,11 @@ namespace OC\Repair\NC15; use OCP\IConfig; use OCP\IDBConnection; +use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; use Sabre\VObject\Reader; +use Sabre\VObject\ParseException; class SetVcardDatabaseUID implements IRepairStep { const MAX_ROWS = 1000; @@ -38,11 +40,15 @@ class SetVcardDatabaseUID implements IRepairStep { /** @var IConfig */ private $config; + /** @var ILogger */ + private $logger; + private $updateQuery; - public function __construct(IDBConnection $connection, IConfig $config) { + public function __construct(IDBConnection $connection, IConfig $config, ILogger $logger) { $this->connection = $connection; $this->config = $config; + $this->logger = $logger; } public function getName() { @@ -75,13 +81,20 @@ class SetVcardDatabaseUID implements IRepairStep { * Extract UID from vcard * * @param string $cardData the vcard raw data + * @param IOutput $output the output logger * @return string the uid or empty if none */ - private function getUID(string $cardData): string { - $vCard = Reader::read($cardData); - if ($vCard->UID) { - $uid = $vCard->UID->getValue(); - return $uid; + private function getUID(string $cardData, IOutput $output): string { + try { + $vCard = Reader::read($cardData); + if ($vCard->UID) { + $uid = $vCard->UID->getValue(); + + return $uid; + } + } catch (ParseException $e) { + $output->warning('One vCard is broken. We logged the exception and will continue the repair.'); + $this->logger->logException($e); } return ''; @@ -106,7 +119,7 @@ class SetVcardDatabaseUID implements IRepairStep { $this->updateQuery->execute(); } - private function repair(): int { + private function repair(IOutput $output): int { $this->connection->beginTransaction(); $entries = $this->getInvalidEntries(); $count = 0; @@ -116,7 +129,7 @@ class SetVcardDatabaseUID implements IRepairStep { if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); } - $uid = $this->getUID($cardData); + $uid = $this->getUID($cardData, $output); $this->update($entry['id'], $uid); } $this->connection->commit(); @@ -133,7 +146,7 @@ class SetVcardDatabaseUID implements IRepairStep { public function run(IOutput $output) { if ($this->shouldRun()) { - $count = $this->repair(); + $count = $this->repair($output); $output->info('Fixed ' . $count . ' vcards'); } diff --git a/lib/private/RichObjectStrings/Validator.php b/lib/private/RichObjectStrings/Validator.php index 55a50fc2a48..29980885cf8 100644 --- a/lib/private/RichObjectStrings/Validator.php +++ b/lib/private/RichObjectStrings/Validator.php @@ -71,11 +71,17 @@ class Validator implements IValidator { foreach ($matches[1] as $parameter) { if (!isset($parameters[$parameter])) { throw new InvalidObjectExeption('Parameter is undefined'); - } else { - $this->validateParameter($parameters[$parameter]); } } } + + foreach ($parameters as $parameter) { + if (!\is_array($parameter)) { + throw new InvalidObjectExeption('Parameter is malformed'); + } + + $this->validateParameter($parameter); + } } /** diff --git a/lib/private/Security/SecureRandom.php b/lib/private/Security/SecureRandom.php index 75d9d02a1d3..faab91e7265 100644 --- a/lib/private/Security/SecureRandom.php +++ b/lib/private/Security/SecureRandom.php @@ -37,34 +37,6 @@ use OCP\Security\ISecureRandom; */ class SecureRandom implements ISecureRandom { /** - * Convenience method to get a low strength random number generator. - * - * Low Strength should be used anywhere that random strings are needed - * in a non-cryptographical setting. They are not strong enough to be - * used as keys or salts. They are however useful for one-time use tokens. - * - * @deprecated 9.0.0 Use \OC\Security\SecureRandom::generate directly or random_bytes() / random_int() - * @return $this - */ - public function getLowStrengthGenerator() { - return $this; - } - - /** - * Convenience method to get a medium strength random number generator. - * - * Medium Strength should be used for most needs of a cryptographic nature. - * They are strong enough to be used as keys and salts. However, they do - * take some time and resources to generate, so they should not be over-used - * - * @deprecated 9.0.0 Use \OC\Security\SecureRandom::generate directly or random_bytes() / random_int() - * @return $this - */ - public function getMediumStrengthGenerator() { - return $this; - } - - /** * Generate a random string of specified length. * @param int $length The length of the generated string * @param string $characters An optional list of characters to use if no character list is diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index a2388012fe7..59aefd54cde 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -272,6 +272,7 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php index aab3295405d..0d838c4d06d 100644 --- a/lib/private/Template/IconsCacher.php +++ b/lib/private/Template/IconsCacher.php @@ -58,6 +58,9 @@ class IconsCacher { private $iconList = 'icons-list.template'; + private $cachedCss; + private $cachedList; + /** * @param ILogger $logger * @param Factory $appDataFactory @@ -137,6 +140,8 @@ class IconsCacher { $cachedVarsCssFile->putContent($data); $list = ":root {\n$list\n}"; $cachedFile->putContent($list); + $this->cachedList = null; + $this->cachedCss = null; } return preg_replace($this->iconVarRE, '', $css); @@ -204,7 +209,10 @@ class IconsCacher { */ public function getCachedCSS() { try { - return $this->folder->getFile($this->fileName); + if (!$this->cachedCss) { + $this->cachedCss = $this->folder->getFile($this->fileName); + } + return $this->cachedCss; } catch (NotFoundException $e) { return false; } @@ -216,7 +224,10 @@ class IconsCacher { */ public function getCachedList() { try { - return $this->folder->getFile($this->iconList); + if (!$this->cachedList) { + $this->cachedList = $this->folder->getFile($this->iconList); + } + return $this->cachedList; } catch (NotFoundException $e) { return false; } diff --git a/lib/private/legacy/defaults.php b/lib/private/legacy/defaults.php index 0c95c1b81b7..d313366abe7 100644 --- a/lib/private/legacy/defaults.php +++ b/lib/private/legacy/defaults.php @@ -36,7 +36,6 @@ class OC_Defaults { private $theme; - private $l; private $defaultEntity; private $defaultName; @@ -53,7 +52,7 @@ class OC_Defaults { private $defaultTextColorPrimary; public function __construct() { - $this->l = \OC::$server->getL10N('lib'); + $l10n = \OC::$server->getL10N('lib'); $config = \OC::$server->getConfig(); $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ @@ -65,8 +64,8 @@ class OC_Defaults { $this->defaultiTunesAppId = $config->getSystemValue('customclient_ios_appid', '1125420102'); $this->defaultAndroidClientUrl = $config->getSystemValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client'); $this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; - $this->defaultDocVersion = '14'; // used to generate doc links - $this->defaultSlogan = $this->l->t('a safe home for all your data'); + $this->defaultDocVersion = \OC_Util::getVersion()[0]; // used to generate doc links + $this->defaultSlogan = $l10n->t('a safe home for all your data'); $this->defaultColorPrimary = '#0082c9'; $this->defaultTextColorPrimary = '#ffffff'; diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 07482a693f5..a94ced8bb1f 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -827,7 +827,7 @@ class OC_Util { ), 'functions' => [ 'xml_parser_create' => 'libxml', - 'mb_strcut' => 'mb multibyte', + 'mb_strcut' => 'mbstring', 'ctype_digit' => 'ctype', 'json_encode' => 'JSON', 'gd_info' => 'GD', diff --git a/lib/public/AppFramework/Db/DoesNotExistException.php b/lib/public/AppFramework/Db/DoesNotExistException.php index b8adc36c7ba..9823a0a1fa8 100644 --- a/lib/public/AppFramework/Db/DoesNotExistException.php +++ b/lib/public/AppFramework/Db/DoesNotExistException.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -30,7 +31,7 @@ namespace OCP\AppFramework\Db; * entry in the database * @since 7.0.0 */ -class DoesNotExistException extends \Exception { +class DoesNotExistException extends \Exception implements IMapperException { /** * Constructor diff --git a/lib/public/AppFramework/Db/IMapperException.php b/lib/public/AppFramework/Db/IMapperException.php new file mode 100644 index 00000000000..dbb9883ae88 --- /dev/null +++ b/lib/public/AppFramework/Db/IMapperException.php @@ -0,0 +1,30 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\AppFramework\Db; + +/** + * @since 16.0.0 + */ +interface IMapperException {} diff --git a/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php b/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php index a17d95e0ef1..3955c417d57 100644 --- a/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php +++ b/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -30,7 +31,7 @@ namespace OCP\AppFramework\Db; * row * @since 7.0.0 */ -class MultipleObjectsReturnedException extends \Exception { +class MultipleObjectsReturnedException extends \Exception implements IMapperException { /** * Constructor diff --git a/lib/public/Authentication/TwoFactorAuth/IActivatableByAdmin.php b/lib/public/Authentication/TwoFactorAuth/IActivatableByAdmin.php index 101beb98db1..51f7f08041f 100644 --- a/lib/public/Authentication/TwoFactorAuth/IActivatableByAdmin.php +++ b/lib/public/Authentication/TwoFactorAuth/IActivatableByAdmin.php @@ -40,7 +40,7 @@ interface IActivatableByAdmin extends IProvider { /** * Enable this provider for the given user. * - * @param IUser $user the user to active this provider for + * @param IUser $user the user to activate this provider for * * @return void * diff --git a/lib/public/Authentication/TwoFactorAuth/IDeactivatableByAdmin.php b/lib/public/Authentication/TwoFactorAuth/IDeactivatableByAdmin.php index c08a7c617c1..c5d66130f2f 100644 --- a/lib/public/Authentication/TwoFactorAuth/IDeactivatableByAdmin.php +++ b/lib/public/Authentication/TwoFactorAuth/IDeactivatableByAdmin.php @@ -40,7 +40,7 @@ interface IDeactivatableByAdmin extends IProvider { /** * Disable this provider for the given user. * - * @param IUser $user the user to active this provider for + * @param IUser $user the user to deactivate this provider for * * @return void * diff --git a/lib/public/L10N/IFactory.php b/lib/public/L10N/IFactory.php index a11977f8c03..de904d0eec1 100644 --- a/lib/public/L10N/IFactory.php +++ b/lib/public/L10N/IFactory.php @@ -32,10 +32,11 @@ interface IFactory { * * @param string $app * @param string|null $lang + * @param string|null $locale * @return \OCP\IL10N * @since 8.2.0 */ - public function get($app, $lang = null); + public function get($app, $lang = null, $locale = null); /** * Find the best language diff --git a/lib/public/Security/ISecureRandom.php b/lib/public/Security/ISecureRandom.php index 235b3033c44..d2ccae67ebe 100644 --- a/lib/public/Security/ISecureRandom.php +++ b/lib/public/Security/ISecureRandom.php @@ -55,32 +55,6 @@ interface ISecureRandom { const CHAR_HUMAN_READABLE = 'abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789'; /** - * Convenience method to get a low strength random number generator. - * - * Low Strength should be used anywhere that random strings are needed - * in a non-cryptographical setting. They are not strong enough to be - * used as keys or salts. They are however useful for one-time use tokens. - * - * @return $this - * @since 8.0.0 - * @deprecated 9.0.0 Use \OC\Security\SecureRandom::generate directly or random_bytes() / random_int() - */ - public function getLowStrengthGenerator(); - - /** - * Convenience method to get a medium strength random number generator. - * - * Medium Strength should be used for most needs of a cryptographic nature. - * They are strong enough to be used as keys and salts. However, they do - * take some time and resources to generate, so they should not be over-used - * - * @return $this - * @since 8.0.0 - * @deprecated 9.0.0 Use \OC\Security\SecureRandom::generate directly or random_bytes() / random_int() - */ - public function getMediumStrengthGenerator(); - - /** * Generate a random string of specified length. * @param int $length The length of the generated string * @param string $characters An optional list of characters to use if no character list is |