@@ -33,12 +33,12 @@ |
||
| 33 | 33 | * @since 25.0.0 |
| 34 | 34 | */ |
| 35 | 35 | interface ISizeEstimationMigrator { |
| 36 | - /** |
|
| 37 | - * Returns an estimate of the exported data size in KiB. |
|
| 38 | - * Should be fast, favor performance over accuracy. |
|
| 39 | - * |
|
| 40 | - * @since 25.0.0 |
|
| 41 | - * @since 27.0.0 return value may overflow from int to float |
|
| 42 | - */ |
|
| 43 | - public function getEstimatedExportSize(IUser $user): int|float; |
|
| 36 | + /** |
|
| 37 | + * Returns an estimate of the exported data size in KiB. |
|
| 38 | + * Should be fast, favor performance over accuracy. |
|
| 39 | + * |
|
| 40 | + * @since 25.0.0 |
|
| 41 | + * @since 27.0.0 return value may overflow from int to float |
|
| 42 | + */ |
|
| 43 | + public function getEstimatedExportSize(IUser $user): int|float; |
|
| 44 | 44 | } |
@@ -37,64 +37,64 @@ |
||
| 37 | 37 | * @since 22.0.0 |
| 38 | 38 | */ |
| 39 | 39 | interface IAccountPropertyCollection extends JsonSerializable { |
| 40 | - /** |
|
| 41 | - * returns the collection name |
|
| 42 | - * |
|
| 43 | - * @since 22.0.0 |
|
| 44 | - */ |
|
| 45 | - public function getName(): string; |
|
| 40 | + /** |
|
| 41 | + * returns the collection name |
|
| 42 | + * |
|
| 43 | + * @since 22.0.0 |
|
| 44 | + */ |
|
| 45 | + public function getName(): string; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * set properties of this collection |
|
| 49 | - * |
|
| 50 | - * @param IAccountProperty[] $properties |
|
| 51 | - * @throws InvalidArgumentException |
|
| 52 | - * @since 22.0.0 |
|
| 53 | - */ |
|
| 54 | - public function setProperties(array $properties): IAccountPropertyCollection; |
|
| 47 | + /** |
|
| 48 | + * set properties of this collection |
|
| 49 | + * |
|
| 50 | + * @param IAccountProperty[] $properties |
|
| 51 | + * @throws InvalidArgumentException |
|
| 52 | + * @since 22.0.0 |
|
| 53 | + */ |
|
| 54 | + public function setProperties(array $properties): IAccountPropertyCollection; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return IAccountProperty[] |
|
| 58 | - * @since 22.0.0 |
|
| 59 | - */ |
|
| 60 | - public function getProperties(): array; |
|
| 56 | + /** |
|
| 57 | + * @return IAccountProperty[] |
|
| 58 | + * @since 22.0.0 |
|
| 59 | + */ |
|
| 60 | + public function getProperties(): array; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * adds a property to this collection |
|
| 64 | - * |
|
| 65 | - * @throws InvalidArgumentException |
|
| 66 | - * @since 22.0.0 |
|
| 67 | - */ |
|
| 68 | - public function addProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
| 62 | + /** |
|
| 63 | + * adds a property to this collection |
|
| 64 | + * |
|
| 65 | + * @throws InvalidArgumentException |
|
| 66 | + * @since 22.0.0 |
|
| 67 | + */ |
|
| 68 | + public function addProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * adds a property to this collection with only specifying the value |
|
| 72 | - * |
|
| 73 | - * @throws InvalidArgumentException |
|
| 74 | - * @since 22.0.0 |
|
| 75 | - */ |
|
| 76 | - public function addPropertyWithDefaults(string $value): IAccountPropertyCollection; |
|
| 70 | + /** |
|
| 71 | + * adds a property to this collection with only specifying the value |
|
| 72 | + * |
|
| 73 | + * @throws InvalidArgumentException |
|
| 74 | + * @since 22.0.0 |
|
| 75 | + */ |
|
| 76 | + public function addPropertyWithDefaults(string $value): IAccountPropertyCollection; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * removes a property of this collection |
|
| 80 | - * |
|
| 81 | - * @since 22.0.0 |
|
| 82 | - */ |
|
| 83 | - public function removeProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
| 78 | + /** |
|
| 79 | + * removes a property of this collection |
|
| 80 | + * |
|
| 81 | + * @since 22.0.0 |
|
| 82 | + */ |
|
| 83 | + public function removeProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * removes a property identified by its value |
|
| 87 | - * |
|
| 88 | - * @since 22.0.0 |
|
| 89 | - */ |
|
| 90 | - public function removePropertyByValue(string $value): IAccountPropertyCollection; |
|
| 85 | + /** |
|
| 86 | + * removes a property identified by its value |
|
| 87 | + * |
|
| 88 | + * @since 22.0.0 |
|
| 89 | + */ |
|
| 90 | + public function removePropertyByValue(string $value): IAccountPropertyCollection; |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * retrieves a property identified by its value. null, if none was found. |
|
| 94 | - * |
|
| 95 | - * Returns only the first property if there are more with the same value. |
|
| 96 | - * |
|
| 97 | - * @since 23.0.0 |
|
| 98 | - */ |
|
| 99 | - public function getPropertyByValue(string $value): ?IAccountProperty; |
|
| 92 | + /** |
|
| 93 | + * retrieves a property identified by its value. null, if none was found. |
|
| 94 | + * |
|
| 95 | + * Returns only the first property if there are more with the same value. |
|
| 96 | + * |
|
| 97 | + * @since 23.0.0 |
|
| 98 | + */ |
|
| 99 | + public function getPropertyByValue(string $value): ?IAccountProperty; |
|
| 100 | 100 | } |
@@ -31,68 +31,68 @@ |
||
| 31 | 31 | * @since 18.0.0 |
| 32 | 32 | */ |
| 33 | 33 | interface IEditor { |
| 34 | - /** |
|
| 35 | - * Return a unique identifier for the editor |
|
| 36 | - * |
|
| 37 | - * e.g. richdocuments |
|
| 38 | - * |
|
| 39 | - * @since 18.0.0 |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function getId(): string; |
|
| 34 | + /** |
|
| 35 | + * Return a unique identifier for the editor |
|
| 36 | + * |
|
| 37 | + * e.g. richdocuments |
|
| 38 | + * |
|
| 39 | + * @since 18.0.0 |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function getId(): string; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Return a readable name for the editor |
|
| 46 | - * |
|
| 47 | - * e.g. Collabora Online |
|
| 48 | - * |
|
| 49 | - * @since 18.0.0 |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 52 | - public function getName(): string; |
|
| 44 | + /** |
|
| 45 | + * Return a readable name for the editor |
|
| 46 | + * |
|
| 47 | + * e.g. Collabora Online |
|
| 48 | + * |
|
| 49 | + * @since 18.0.0 |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | + public function getName(): string; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * A list of mimetypes that should open the editor by default |
|
| 56 | - * |
|
| 57 | - * @since 18.0.0 |
|
| 58 | - * @return string[] |
|
| 59 | - */ |
|
| 60 | - public function getMimetypes(): array; |
|
| 54 | + /** |
|
| 55 | + * A list of mimetypes that should open the editor by default |
|
| 56 | + * |
|
| 57 | + * @since 18.0.0 |
|
| 58 | + * @return string[] |
|
| 59 | + */ |
|
| 60 | + public function getMimetypes(): array; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * A list of mimetypes that can be opened in the editor optionally |
|
| 64 | - * |
|
| 65 | - * @since 18.0.0 |
|
| 66 | - * @return string[] |
|
| 67 | - */ |
|
| 68 | - public function getMimetypesOptional(): array; |
|
| 62 | + /** |
|
| 63 | + * A list of mimetypes that can be opened in the editor optionally |
|
| 64 | + * |
|
| 65 | + * @since 18.0.0 |
|
| 66 | + * @return string[] |
|
| 67 | + */ |
|
| 68 | + public function getMimetypesOptional(): array; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Return a list of file creation options to be presented to the user |
|
| 72 | - * |
|
| 73 | - * @since 18.0.0 |
|
| 74 | - * @return ACreateFromTemplate[]|ACreateEmpty[] |
|
| 75 | - */ |
|
| 76 | - public function getCreators(): array; |
|
| 70 | + /** |
|
| 71 | + * Return a list of file creation options to be presented to the user |
|
| 72 | + * |
|
| 73 | + * @since 18.0.0 |
|
| 74 | + * @return ACreateFromTemplate[]|ACreateEmpty[] |
|
| 75 | + */ |
|
| 76 | + public function getCreators(): array; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Return if the view is able to securely view a file without downloading it to the browser |
|
| 80 | - * |
|
| 81 | - * @since 18.0.0 |
|
| 82 | - * @return bool |
|
| 83 | - */ |
|
| 84 | - public function isSecure(): bool; |
|
| 78 | + /** |
|
| 79 | + * Return if the view is able to securely view a file without downloading it to the browser |
|
| 80 | + * |
|
| 81 | + * @since 18.0.0 |
|
| 82 | + * @return bool |
|
| 83 | + */ |
|
| 84 | + public function isSecure(): bool; |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Return a template response for displaying the editor |
|
| 88 | - * |
|
| 89 | - * open can only be called once when the client requests the editor with a one-time-use token |
|
| 90 | - * For handling editing and later requests, editors need to implement their own token handling and take care of invalidation |
|
| 91 | - * |
|
| 92 | - * This behavior is similar to the current direct editing implementation in collabora where we generate a one-time token and switch over to the regular wopi token for the actual editing/saving process |
|
| 93 | - * |
|
| 94 | - * @since 18.0.0 |
|
| 95 | - * @return Response |
|
| 96 | - */ |
|
| 97 | - public function open(IToken $token): Response; |
|
| 86 | + /** |
|
| 87 | + * Return a template response for displaying the editor |
|
| 88 | + * |
|
| 89 | + * open can only be called once when the client requests the editor with a one-time-use token |
|
| 90 | + * For handling editing and later requests, editors need to implement their own token handling and take care of invalidation |
|
| 91 | + * |
|
| 92 | + * This behavior is similar to the current direct editing implementation in collabora where we generate a one-time token and switch over to the regular wopi token for the actual editing/saving process |
|
| 93 | + * |
|
| 94 | + * @since 18.0.0 |
|
| 95 | + * @return Response |
|
| 96 | + */ |
|
| 97 | + public function open(IToken $token): Response; |
|
| 98 | 98 | } |
@@ -31,38 +31,38 @@ |
||
| 31 | 31 | use OCP\Files\Cache\ICacheEntry; |
| 32 | 32 | |
| 33 | 33 | class HomeCache extends Cache { |
| 34 | - /** |
|
| 35 | - * get the size of a folder and set it in the cache |
|
| 36 | - * |
|
| 37 | - * @param string $path |
|
| 38 | - * @param array|null|ICacheEntry $entry (optional) meta data of the folder |
|
| 39 | - * @return int|float |
|
| 40 | - */ |
|
| 41 | - public function calculateFolderSize($path, $entry = null) { |
|
| 42 | - if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { |
|
| 43 | - return parent::calculateFolderSize($path, $entry); |
|
| 44 | - } elseif ($path === '' or $path === '/') { |
|
| 45 | - // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it |
|
| 46 | - return 0; |
|
| 47 | - } else { |
|
| 48 | - return $this->calculateFolderSizeInner($path, $entry, true); |
|
| 49 | - } |
|
| 50 | - } |
|
| 34 | + /** |
|
| 35 | + * get the size of a folder and set it in the cache |
|
| 36 | + * |
|
| 37 | + * @param string $path |
|
| 38 | + * @param array|null|ICacheEntry $entry (optional) meta data of the folder |
|
| 39 | + * @return int|float |
|
| 40 | + */ |
|
| 41 | + public function calculateFolderSize($path, $entry = null) { |
|
| 42 | + if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { |
|
| 43 | + return parent::calculateFolderSize($path, $entry); |
|
| 44 | + } elseif ($path === '' or $path === '/') { |
|
| 45 | + // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it |
|
| 46 | + return 0; |
|
| 47 | + } else { |
|
| 48 | + return $this->calculateFolderSizeInner($path, $entry, true); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @param string $file |
|
| 54 | - * @return ICacheEntry |
|
| 55 | - */ |
|
| 56 | - public function get($file) { |
|
| 57 | - $data = parent::get($file); |
|
| 58 | - if ($file === '' or $file === '/') { |
|
| 59 | - // only the size of the "files" dir counts |
|
| 60 | - $filesData = parent::get('files'); |
|
| 52 | + /** |
|
| 53 | + * @param string $file |
|
| 54 | + * @return ICacheEntry |
|
| 55 | + */ |
|
| 56 | + public function get($file) { |
|
| 57 | + $data = parent::get($file); |
|
| 58 | + if ($file === '' or $file === '/') { |
|
| 59 | + // only the size of the "files" dir counts |
|
| 60 | + $filesData = parent::get('files'); |
|
| 61 | 61 | |
| 62 | - if (isset($filesData['size'])) { |
|
| 63 | - $data['size'] = $filesData['size']; |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - return $data; |
|
| 67 | - } |
|
| 62 | + if (isset($filesData['size'])) { |
|
| 63 | + $data['size'] = $filesData['size']; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + return $data; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -37,70 +37,70 @@ |
||
| 37 | 37 | * @since 24.0.0 |
| 38 | 38 | */ |
| 39 | 39 | trait TTransactional { |
| 40 | - /** |
|
| 41 | - * Run an atomic database operation |
|
| 42 | - * |
|
| 43 | - * - Commit if no exceptions are thrown, return the callable result |
|
| 44 | - * - Revert otherwise and rethrows the exception |
|
| 45 | - * |
|
| 46 | - * @template T |
|
| 47 | - * @param callable $fn |
|
| 48 | - * @psalm-param callable():T $fn |
|
| 49 | - * @param IDBConnection $db |
|
| 50 | - * |
|
| 51 | - * @return mixed the result of the passed callable |
|
| 52 | - * @psalm-return T |
|
| 53 | - * |
|
| 54 | - * @throws Exception for possible errors of commit or rollback or the custom operations within the closure |
|
| 55 | - * @throws Throwable any other error caused by the closure |
|
| 56 | - * |
|
| 57 | - * @since 24.0.0 |
|
| 58 | - * @see https://docs.nextcloud.com/server/latest/developer_manual/basics/storage/database.html#transactions |
|
| 59 | - */ |
|
| 60 | - protected function atomic(callable $fn, IDBConnection $db) { |
|
| 61 | - $db->beginTransaction(); |
|
| 62 | - try { |
|
| 63 | - $result = $fn(); |
|
| 64 | - $db->commit(); |
|
| 65 | - return $result; |
|
| 66 | - } catch (Throwable $e) { |
|
| 67 | - $db->rollBack(); |
|
| 68 | - throw $e; |
|
| 69 | - } |
|
| 70 | - } |
|
| 40 | + /** |
|
| 41 | + * Run an atomic database operation |
|
| 42 | + * |
|
| 43 | + * - Commit if no exceptions are thrown, return the callable result |
|
| 44 | + * - Revert otherwise and rethrows the exception |
|
| 45 | + * |
|
| 46 | + * @template T |
|
| 47 | + * @param callable $fn |
|
| 48 | + * @psalm-param callable():T $fn |
|
| 49 | + * @param IDBConnection $db |
|
| 50 | + * |
|
| 51 | + * @return mixed the result of the passed callable |
|
| 52 | + * @psalm-return T |
|
| 53 | + * |
|
| 54 | + * @throws Exception for possible errors of commit or rollback or the custom operations within the closure |
|
| 55 | + * @throws Throwable any other error caused by the closure |
|
| 56 | + * |
|
| 57 | + * @since 24.0.0 |
|
| 58 | + * @see https://docs.nextcloud.com/server/latest/developer_manual/basics/storage/database.html#transactions |
|
| 59 | + */ |
|
| 60 | + protected function atomic(callable $fn, IDBConnection $db) { |
|
| 61 | + $db->beginTransaction(); |
|
| 62 | + try { |
|
| 63 | + $result = $fn(); |
|
| 64 | + $db->commit(); |
|
| 65 | + return $result; |
|
| 66 | + } catch (Throwable $e) { |
|
| 67 | + $db->rollBack(); |
|
| 68 | + throw $e; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Wrapper around atomic() to retry after a retryable exception occurred |
|
| 74 | - * |
|
| 75 | - * Certain transactions might need to be retried. This is especially useful |
|
| 76 | - * in highly concurrent requests where a deadlocks is thrown by the database |
|
| 77 | - * without waiting for the lock to be freed (e.g. due to MySQL/MariaDB deadlock |
|
| 78 | - * detection) |
|
| 79 | - * |
|
| 80 | - * @template T |
|
| 81 | - * @param callable $fn |
|
| 82 | - * @psalm-param callable():T $fn |
|
| 83 | - * @param IDBConnection $db |
|
| 84 | - * @param int $maxRetries |
|
| 85 | - * |
|
| 86 | - * @return mixed the result of the passed callable |
|
| 87 | - * @psalm-return T |
|
| 88 | - * |
|
| 89 | - * @throws Exception for possible errors of commit or rollback or the custom operations within the closure |
|
| 90 | - * @throws Throwable any other error caused by the closure |
|
| 91 | - * |
|
| 92 | - * @since 27.0.0 |
|
| 93 | - */ |
|
| 94 | - protected function atomicRetry(callable $fn, IDBConnection $db, int $maxRetries = 3): mixed { |
|
| 95 | - for ($i = 0; $i < $maxRetries; $i++) { |
|
| 96 | - try { |
|
| 97 | - return $this->atomic($fn, $db); |
|
| 98 | - } catch (DbalException $e) { |
|
| 99 | - if (!$e->isRetryable() || $i === ($maxRetries - 1)) { |
|
| 100 | - throw $e; |
|
| 101 | - } |
|
| 102 | - logger('core')->warning('Retrying operation after retryable exception.', [ 'exception' => $e ]); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - } |
|
| 72 | + /** |
|
| 73 | + * Wrapper around atomic() to retry after a retryable exception occurred |
|
| 74 | + * |
|
| 75 | + * Certain transactions might need to be retried. This is especially useful |
|
| 76 | + * in highly concurrent requests where a deadlocks is thrown by the database |
|
| 77 | + * without waiting for the lock to be freed (e.g. due to MySQL/MariaDB deadlock |
|
| 78 | + * detection) |
|
| 79 | + * |
|
| 80 | + * @template T |
|
| 81 | + * @param callable $fn |
|
| 82 | + * @psalm-param callable():T $fn |
|
| 83 | + * @param IDBConnection $db |
|
| 84 | + * @param int $maxRetries |
|
| 85 | + * |
|
| 86 | + * @return mixed the result of the passed callable |
|
| 87 | + * @psalm-return T |
|
| 88 | + * |
|
| 89 | + * @throws Exception for possible errors of commit or rollback or the custom operations within the closure |
|
| 90 | + * @throws Throwable any other error caused by the closure |
|
| 91 | + * |
|
| 92 | + * @since 27.0.0 |
|
| 93 | + */ |
|
| 94 | + protected function atomicRetry(callable $fn, IDBConnection $db, int $maxRetries = 3): mixed { |
|
| 95 | + for ($i = 0; $i < $maxRetries; $i++) { |
|
| 96 | + try { |
|
| 97 | + return $this->atomic($fn, $db); |
|
| 98 | + } catch (DbalException $e) { |
|
| 99 | + if (!$e->isRetryable() || $i === ($maxRetries - 1)) { |
|
| 100 | + throw $e; |
|
| 101 | + } |
|
| 102 | + logger('core')->warning('Retrying operation after retryable exception.', [ 'exception' => $e ]); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | 106 | } |
@@ -28,67 +28,67 @@ |
||
| 28 | 28 | namespace OC\L10N; |
| 29 | 29 | |
| 30 | 30 | class L10NString implements \JsonSerializable { |
| 31 | - /** @var L10N */ |
|
| 32 | - protected $l10n; |
|
| 31 | + /** @var L10N */ |
|
| 32 | + protected $l10n; |
|
| 33 | 33 | |
| 34 | - /** @var string */ |
|
| 35 | - protected $text; |
|
| 34 | + /** @var string */ |
|
| 35 | + protected $text; |
|
| 36 | 36 | |
| 37 | - /** @var array */ |
|
| 38 | - protected $parameters; |
|
| 37 | + /** @var array */ |
|
| 38 | + protected $parameters; |
|
| 39 | 39 | |
| 40 | - /** @var integer */ |
|
| 41 | - protected $count; |
|
| 40 | + /** @var integer */ |
|
| 41 | + protected $count; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param L10N $l10n |
|
| 45 | - * @param string|string[] $text |
|
| 46 | - * @param array $parameters |
|
| 47 | - * @param int $count |
|
| 48 | - */ |
|
| 49 | - public function __construct(L10N $l10n, $text, array $parameters, int $count = 1) { |
|
| 50 | - $this->l10n = $l10n; |
|
| 51 | - $this->text = $text; |
|
| 52 | - $this->parameters = $parameters; |
|
| 53 | - $this->count = $count; |
|
| 54 | - } |
|
| 43 | + /** |
|
| 44 | + * @param L10N $l10n |
|
| 45 | + * @param string|string[] $text |
|
| 46 | + * @param array $parameters |
|
| 47 | + * @param int $count |
|
| 48 | + */ |
|
| 49 | + public function __construct(L10N $l10n, $text, array $parameters, int $count = 1) { |
|
| 50 | + $this->l10n = $l10n; |
|
| 51 | + $this->text = $text; |
|
| 52 | + $this->parameters = $parameters; |
|
| 53 | + $this->count = $count; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - public function __toString(): string { |
|
| 57 | - $translations = $this->l10n->getTranslations(); |
|
| 58 | - $identityTranslator = $this->l10n->getIdentityTranslator(); |
|
| 56 | + public function __toString(): string { |
|
| 57 | + $translations = $this->l10n->getTranslations(); |
|
| 58 | + $identityTranslator = $this->l10n->getIdentityTranslator(); |
|
| 59 | 59 | |
| 60 | - // Use the indexed version as per \Symfony\Contracts\Translation\TranslatorInterface |
|
| 61 | - $identity = $this->text; |
|
| 62 | - if (array_key_exists($this->text, $translations)) { |
|
| 63 | - $identity = $translations[$this->text]; |
|
| 64 | - } |
|
| 60 | + // Use the indexed version as per \Symfony\Contracts\Translation\TranslatorInterface |
|
| 61 | + $identity = $this->text; |
|
| 62 | + if (array_key_exists($this->text, $translations)) { |
|
| 63 | + $identity = $translations[$this->text]; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - if (is_array($identity)) { |
|
| 67 | - $pipeCheck = implode('', $identity); |
|
| 68 | - if (str_contains($pipeCheck, '|')) { |
|
| 69 | - return 'Can not use pipe character in translations'; |
|
| 70 | - } |
|
| 66 | + if (is_array($identity)) { |
|
| 67 | + $pipeCheck = implode('', $identity); |
|
| 68 | + if (str_contains($pipeCheck, '|')) { |
|
| 69 | + return 'Can not use pipe character in translations'; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $identity = implode('|', $identity); |
|
| 73 | - } elseif (str_contains($identity, '|')) { |
|
| 74 | - return 'Can not use pipe character in translations'; |
|
| 75 | - } |
|
| 72 | + $identity = implode('|', $identity); |
|
| 73 | + } elseif (str_contains($identity, '|')) { |
|
| 74 | + return 'Can not use pipe character in translations'; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $beforeIdentity = $identity; |
|
| 78 | - $identity = str_replace('%n', '%count%', $identity); |
|
| 77 | + $beforeIdentity = $identity; |
|
| 78 | + $identity = str_replace('%n', '%count%', $identity); |
|
| 79 | 79 | |
| 80 | - $parameters = []; |
|
| 81 | - if ($beforeIdentity !== $identity) { |
|
| 82 | - $parameters = ['%count%' => $this->count]; |
|
| 83 | - } |
|
| 80 | + $parameters = []; |
|
| 81 | + if ($beforeIdentity !== $identity) { |
|
| 82 | + $parameters = ['%count%' => $this->count]; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - // $count as %count% as per \Symfony\Contracts\Translation\TranslatorInterface |
|
| 86 | - $text = $identityTranslator->trans($identity, $parameters); |
|
| 85 | + // $count as %count% as per \Symfony\Contracts\Translation\TranslatorInterface |
|
| 86 | + $text = $identityTranslator->trans($identity, $parameters); |
|
| 87 | 87 | |
| 88 | - return vsprintf($text, $this->parameters); |
|
| 89 | - } |
|
| 88 | + return vsprintf($text, $this->parameters); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - public function jsonSerialize(): string { |
|
| 92 | - return $this->__toString(); |
|
| 93 | - } |
|
| 91 | + public function jsonSerialize(): string { |
|
| 92 | + return $this->__toString(); |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -35,56 +35,56 @@ |
||
| 35 | 35 | use OCP\IRequest; |
| 36 | 36 | |
| 37 | 37 | class CompressionMiddleware extends Middleware { |
| 38 | - /** @var bool */ |
|
| 39 | - private $useGZip; |
|
| 38 | + /** @var bool */ |
|
| 39 | + private $useGZip; |
|
| 40 | 40 | |
| 41 | - /** @var IRequest */ |
|
| 42 | - private $request; |
|
| 41 | + /** @var IRequest */ |
|
| 42 | + private $request; |
|
| 43 | 43 | |
| 44 | - public function __construct(IRequest $request) { |
|
| 45 | - $this->request = $request; |
|
| 46 | - $this->useGZip = false; |
|
| 47 | - } |
|
| 44 | + public function __construct(IRequest $request) { |
|
| 45 | + $this->request = $request; |
|
| 46 | + $this->useGZip = false; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function afterController($controller, $methodName, Response $response) { |
|
| 50 | - // By default we do not gzip |
|
| 51 | - $allowGzip = false; |
|
| 49 | + public function afterController($controller, $methodName, Response $response) { |
|
| 50 | + // By default we do not gzip |
|
| 51 | + $allowGzip = false; |
|
| 52 | 52 | |
| 53 | - // Only return gzipped content for 200 responses |
|
| 54 | - if ($response->getStatus() !== Http::STATUS_OK) { |
|
| 55 | - return $response; |
|
| 56 | - } |
|
| 53 | + // Only return gzipped content for 200 responses |
|
| 54 | + if ($response->getStatus() !== Http::STATUS_OK) { |
|
| 55 | + return $response; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - // Check if we are even asked for gzip |
|
| 59 | - $header = $this->request->getHeader('Accept-Encoding'); |
|
| 60 | - if (!str_contains($header, 'gzip')) { |
|
| 61 | - return $response; |
|
| 62 | - } |
|
| 58 | + // Check if we are even asked for gzip |
|
| 59 | + $header = $this->request->getHeader('Accept-Encoding'); |
|
| 60 | + if (!str_contains($header, 'gzip')) { |
|
| 61 | + return $response; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - // We only allow gzip in some cases |
|
| 65 | - if ($response instanceof BaseResponse) { |
|
| 66 | - $allowGzip = true; |
|
| 67 | - } |
|
| 68 | - if ($response instanceof JSONResponse) { |
|
| 69 | - $allowGzip = true; |
|
| 70 | - } |
|
| 71 | - if ($response instanceof TemplateResponse) { |
|
| 72 | - $allowGzip = true; |
|
| 73 | - } |
|
| 64 | + // We only allow gzip in some cases |
|
| 65 | + if ($response instanceof BaseResponse) { |
|
| 66 | + $allowGzip = true; |
|
| 67 | + } |
|
| 68 | + if ($response instanceof JSONResponse) { |
|
| 69 | + $allowGzip = true; |
|
| 70 | + } |
|
| 71 | + if ($response instanceof TemplateResponse) { |
|
| 72 | + $allowGzip = true; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - if ($allowGzip) { |
|
| 76 | - $this->useGZip = true; |
|
| 77 | - $response->addHeader('Content-Encoding', 'gzip'); |
|
| 78 | - } |
|
| 75 | + if ($allowGzip) { |
|
| 76 | + $this->useGZip = true; |
|
| 77 | + $response->addHeader('Content-Encoding', 'gzip'); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - return $response; |
|
| 81 | - } |
|
| 80 | + return $response; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - public function beforeOutput($controller, $methodName, $output) { |
|
| 84 | - if (!$this->useGZip) { |
|
| 85 | - return $output; |
|
| 86 | - } |
|
| 83 | + public function beforeOutput($controller, $methodName, $output) { |
|
| 84 | + if (!$this->useGZip) { |
|
| 85 | + return $output; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - return gzencode($output); |
|
| 89 | - } |
|
| 88 | + return gzencode($output); |
|
| 89 | + } |
|
| 90 | 90 | } |
@@ -27,133 +27,133 @@ |
||
| 27 | 27 | use OCP\IMemcache; |
| 28 | 28 | |
| 29 | 29 | class ArrayCache extends Cache implements IMemcache { |
| 30 | - /** @var array Array with the cached data */ |
|
| 31 | - protected $cachedData = []; |
|
| 30 | + /** @var array Array with the cached data */ |
|
| 31 | + protected $cachedData = []; |
|
| 32 | 32 | |
| 33 | - use CADTrait; |
|
| 33 | + use CADTrait; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * {@inheritDoc} |
|
| 37 | - */ |
|
| 38 | - public function get($key) { |
|
| 39 | - if ($this->hasKey($key)) { |
|
| 40 | - return $this->cachedData[$key]; |
|
| 41 | - } |
|
| 42 | - return null; |
|
| 43 | - } |
|
| 35 | + /** |
|
| 36 | + * {@inheritDoc} |
|
| 37 | + */ |
|
| 38 | + public function get($key) { |
|
| 39 | + if ($this->hasKey($key)) { |
|
| 40 | + return $this->cachedData[$key]; |
|
| 41 | + } |
|
| 42 | + return null; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * {@inheritDoc} |
|
| 47 | - */ |
|
| 48 | - public function set($key, $value, $ttl = 0) { |
|
| 49 | - $this->cachedData[$key] = $value; |
|
| 50 | - return true; |
|
| 51 | - } |
|
| 45 | + /** |
|
| 46 | + * {@inheritDoc} |
|
| 47 | + */ |
|
| 48 | + public function set($key, $value, $ttl = 0) { |
|
| 49 | + $this->cachedData[$key] = $value; |
|
| 50 | + return true; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * {@inheritDoc} |
|
| 55 | - */ |
|
| 56 | - public function hasKey($key) { |
|
| 57 | - return isset($this->cachedData[$key]); |
|
| 58 | - } |
|
| 53 | + /** |
|
| 54 | + * {@inheritDoc} |
|
| 55 | + */ |
|
| 56 | + public function hasKey($key) { |
|
| 57 | + return isset($this->cachedData[$key]); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * {@inheritDoc} |
|
| 62 | - */ |
|
| 63 | - public function remove($key) { |
|
| 64 | - unset($this->cachedData[$key]); |
|
| 65 | - return true; |
|
| 66 | - } |
|
| 60 | + /** |
|
| 61 | + * {@inheritDoc} |
|
| 62 | + */ |
|
| 63 | + public function remove($key) { |
|
| 64 | + unset($this->cachedData[$key]); |
|
| 65 | + return true; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * {@inheritDoc} |
|
| 70 | - */ |
|
| 71 | - public function clear($prefix = '') { |
|
| 72 | - if ($prefix === '') { |
|
| 73 | - $this->cachedData = []; |
|
| 74 | - return true; |
|
| 75 | - } |
|
| 68 | + /** |
|
| 69 | + * {@inheritDoc} |
|
| 70 | + */ |
|
| 71 | + public function clear($prefix = '') { |
|
| 72 | + if ($prefix === '') { |
|
| 73 | + $this->cachedData = []; |
|
| 74 | + return true; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - foreach ($this->cachedData as $key => $value) { |
|
| 78 | - if (str_starts_with($key, $prefix)) { |
|
| 79 | - $this->remove($key); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - return true; |
|
| 83 | - } |
|
| 77 | + foreach ($this->cachedData as $key => $value) { |
|
| 78 | + if (str_starts_with($key, $prefix)) { |
|
| 79 | + $this->remove($key); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + return true; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Set a value in the cache if it's not already stored |
|
| 87 | - * |
|
| 88 | - * @param string $key |
|
| 89 | - * @param mixed $value |
|
| 90 | - * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
| 91 | - * @return bool |
|
| 92 | - */ |
|
| 93 | - public function add($key, $value, $ttl = 0) { |
|
| 94 | - // since this cache is not shared race conditions aren't an issue |
|
| 95 | - if ($this->hasKey($key)) { |
|
| 96 | - return false; |
|
| 97 | - } else { |
|
| 98 | - return $this->set($key, $value, $ttl); |
|
| 99 | - } |
|
| 100 | - } |
|
| 85 | + /** |
|
| 86 | + * Set a value in the cache if it's not already stored |
|
| 87 | + * |
|
| 88 | + * @param string $key |
|
| 89 | + * @param mixed $value |
|
| 90 | + * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
| 91 | + * @return bool |
|
| 92 | + */ |
|
| 93 | + public function add($key, $value, $ttl = 0) { |
|
| 94 | + // since this cache is not shared race conditions aren't an issue |
|
| 95 | + if ($this->hasKey($key)) { |
|
| 96 | + return false; |
|
| 97 | + } else { |
|
| 98 | + return $this->set($key, $value, $ttl); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Increase a stored number |
|
| 104 | - * |
|
| 105 | - * @param string $key |
|
| 106 | - * @param int $step |
|
| 107 | - * @return int | bool |
|
| 108 | - */ |
|
| 109 | - public function inc($key, $step = 1) { |
|
| 110 | - $oldValue = $this->get($key); |
|
| 111 | - if (is_int($oldValue)) { |
|
| 112 | - $this->set($key, $oldValue + $step); |
|
| 113 | - return $oldValue + $step; |
|
| 114 | - } else { |
|
| 115 | - $success = $this->add($key, $step); |
|
| 116 | - return $success ? $step : false; |
|
| 117 | - } |
|
| 118 | - } |
|
| 102 | + /** |
|
| 103 | + * Increase a stored number |
|
| 104 | + * |
|
| 105 | + * @param string $key |
|
| 106 | + * @param int $step |
|
| 107 | + * @return int | bool |
|
| 108 | + */ |
|
| 109 | + public function inc($key, $step = 1) { |
|
| 110 | + $oldValue = $this->get($key); |
|
| 111 | + if (is_int($oldValue)) { |
|
| 112 | + $this->set($key, $oldValue + $step); |
|
| 113 | + return $oldValue + $step; |
|
| 114 | + } else { |
|
| 115 | + $success = $this->add($key, $step); |
|
| 116 | + return $success ? $step : false; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Decrease a stored number |
|
| 122 | - * |
|
| 123 | - * @param string $key |
|
| 124 | - * @param int $step |
|
| 125 | - * @return int | bool |
|
| 126 | - */ |
|
| 127 | - public function dec($key, $step = 1) { |
|
| 128 | - $oldValue = $this->get($key); |
|
| 129 | - if (is_int($oldValue)) { |
|
| 130 | - $this->set($key, $oldValue - $step); |
|
| 131 | - return $oldValue - $step; |
|
| 132 | - } else { |
|
| 133 | - return false; |
|
| 134 | - } |
|
| 135 | - } |
|
| 120 | + /** |
|
| 121 | + * Decrease a stored number |
|
| 122 | + * |
|
| 123 | + * @param string $key |
|
| 124 | + * @param int $step |
|
| 125 | + * @return int | bool |
|
| 126 | + */ |
|
| 127 | + public function dec($key, $step = 1) { |
|
| 128 | + $oldValue = $this->get($key); |
|
| 129 | + if (is_int($oldValue)) { |
|
| 130 | + $this->set($key, $oldValue - $step); |
|
| 131 | + return $oldValue - $step; |
|
| 132 | + } else { |
|
| 133 | + return false; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Compare and set |
|
| 139 | - * |
|
| 140 | - * @param string $key |
|
| 141 | - * @param mixed $old |
|
| 142 | - * @param mixed $new |
|
| 143 | - * @return bool |
|
| 144 | - */ |
|
| 145 | - public function cas($key, $old, $new) { |
|
| 146 | - if ($this->get($key) === $old) { |
|
| 147 | - return $this->set($key, $new); |
|
| 148 | - } else { |
|
| 149 | - return false; |
|
| 150 | - } |
|
| 151 | - } |
|
| 137 | + /** |
|
| 138 | + * Compare and set |
|
| 139 | + * |
|
| 140 | + * @param string $key |
|
| 141 | + * @param mixed $old |
|
| 142 | + * @param mixed $new |
|
| 143 | + * @return bool |
|
| 144 | + */ |
|
| 145 | + public function cas($key, $old, $new) { |
|
| 146 | + if ($this->get($key) === $old) { |
|
| 147 | + return $this->set($key, $new); |
|
| 148 | + } else { |
|
| 149 | + return false; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * {@inheritDoc} |
|
| 155 | - */ |
|
| 156 | - public static function isAvailable(): bool { |
|
| 157 | - return true; |
|
| 158 | - } |
|
| 153 | + /** |
|
| 154 | + * {@inheritDoc} |
|
| 155 | + */ |
|
| 156 | + public static function isAvailable(): bool { |
|
| 157 | + return true; |
|
| 158 | + } |
|
| 159 | 159 | } |
@@ -26,24 +26,24 @@ |
||
| 26 | 26 | namespace OC\Files\Cache; |
| 27 | 27 | |
| 28 | 28 | class LocalRootScanner extends Scanner { |
| 29 | - public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) { |
|
| 30 | - if ($this->shouldScanPath($file)) { |
|
| 31 | - return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock, $data); |
|
| 32 | - } else { |
|
| 33 | - return null; |
|
| 34 | - } |
|
| 35 | - } |
|
| 29 | + public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) { |
|
| 30 | + if ($this->shouldScanPath($file)) { |
|
| 31 | + return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock, $data); |
|
| 32 | + } else { |
|
| 33 | + return null; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { |
|
| 38 | - if ($this->shouldScanPath($path)) { |
|
| 39 | - return parent::scan($path, $recursive, $reuse, $lock); |
|
| 40 | - } else { |
|
| 41 | - return null; |
|
| 42 | - } |
|
| 43 | - } |
|
| 37 | + public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { |
|
| 38 | + if ($this->shouldScanPath($path)) { |
|
| 39 | + return parent::scan($path, $recursive, $reuse, $lock); |
|
| 40 | + } else { |
|
| 41 | + return null; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - private function shouldScanPath(string $path): bool { |
|
| 46 | - $path = trim($path, '/'); |
|
| 47 | - return $path === '' || str_starts_with($path, 'appdata_') || str_starts_with($path, '__groupfolders'); |
|
| 48 | - } |
|
| 45 | + private function shouldScanPath(string $path): bool { |
|
| 46 | + $path = trim($path, '/'); |
|
| 47 | + return $path === '' || str_starts_with($path, 'appdata_') || str_starts_with($path, '__groupfolders'); |
|
| 48 | + } |
|
| 49 | 49 | } |