From 257039be80d247136560c0aa2306820310b2231c Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 22 Jun 2023 13:41:48 +0200 Subject: [PATCH 1/3] Backport Server into app --- appinfo/info.xml | 2 +- composer.json | 2 +- composer.lock | 12 ++++----- lib/Hooks.php | 2 +- lib/Utility/Server.php | 57 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 lib/Utility/Server.php diff --git a/appinfo/info.xml b/appinfo/info.xml index fb5f44f..f831774 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -29,7 +29,7 @@ See [README] for more exhaustive information on features and potential misfeatur [README]: https://github.com/e-alfred/epubreader/blob/master/epubreader/README.md ]]> - 1.4.8 + 1.4.9 agpl Frank de Lange e-alfred diff --git a/composer.json b/composer.json index 249771b..3bfa30b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "nextcloud/epubreader", "description": "EPUB/CBZ/PDF ebook reader", - "version": "1.4.8", + "version": "1.4.9", "type": "project", "license": "AGPL-3.0-or-later", "require-dev": { diff --git a/composer.lock b/composer.lock index eaf77a9..9fb3687 100644 --- a/composer.lock +++ b/composer.lock @@ -94,16 +94,16 @@ }, { "name": "php-cs-fixer/shim", - "version": "v3.17.0", + "version": "v3.18.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "f51b4aed90565c447136f1d015798f6f7c82490f" + "reference": "a517e03dd0727336e502e071cc08e406ac878dba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/f51b4aed90565c447136f1d015798f6f7c82490f", - "reference": "f51b4aed90565c447136f1d015798f6f7c82490f", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/a517e03dd0727336e502e071cc08e406ac878dba", + "reference": "a517e03dd0727336e502e071cc08e406ac878dba", "shasum": "" }, "require": { @@ -140,9 +140,9 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/PHP-CS-Fixer/shim/issues", - "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.17.0" + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.18.0" }, - "time": "2023-05-22T20:00:38+00:00" + "time": "2023-06-18T22:26:36+00:00" }, { "name": "psalm/phar", diff --git a/lib/Hooks.php b/lib/Hooks.php index a9a87d0..8ddfe7d 100644 --- a/lib/Hooks.php +++ b/lib/Hooks.php @@ -11,13 +11,13 @@ namespace OCA\Epubreader; use OCA\Epubreader\AppInfo\Application; +use OCA\Epubreader\Utility\Server; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\IConfig; use OCP\IDBConnection; use OCP\IUser; use OCP\IUserSession; -use OCP\Server; class Hooks { diff --git a/lib/Utility/Server.php b/lib/Utility/Server.php new file mode 100644 index 0000000..c62c320 --- /dev/null +++ b/lib/Utility/Server.php @@ -0,0 +1,57 @@ + + * + * @license AGPL-3.0-or-later + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\Epubreader\Utility; + +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; + +/** + * Class allowing to inject services into your application. You should + * use whenever possible dependency injections instead. + * + * ```php + * use OCP\Server; + * + * $tagManager = Server::get(ITagManager::class); + * ``` + * + * @since 25.0.0 + */ +final class Server { + /** + * @template T + * @param class-string|string $serviceName + * @return T|mixed + * @psalm-template S as class-string|string + * @psalm-param S $serviceName + * @psalm-return (S is class-string ? T : mixed) + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @since 25.0.0 + */ + public static function get(string $serviceName) { + /** @psalm-suppress UndefinedClass */ + return \OC::$server->get($serviceName); + } +} From aed2f2db3848ea74377039737e569da25c9e847d Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 22 Jun 2023 13:44:59 +0200 Subject: [PATCH 2/3] up nextcloud compatibility --- .drone.yml | 4 ++-- appinfo/info.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0de7575..3ff7c6b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,8 +3,8 @@ name: default type: docker steps: - - name: nextcloud:21 - image: nextcloud:21 + - name: nextcloud:22 + image: nextcloud:22 commands: - curl -sSLo /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar - chmod +x /usr/local/bin/composer diff --git a/appinfo/info.xml b/appinfo/info.xml index f831774..73caeb8 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -46,7 +46,7 @@ See [README] for more exhaustive information on features and potential misfeatur https://github.com/e-alfred/epubreader/blob/master/screenshots/photo_2017-03-15_17-22-00.jpg?raw=true https://github.com/e-alfred/epubreader/blob/master/screenshots/photo_2017-03-15_17-22-02.jpg?raw=true - + OCA\Epubreader\Settings\Personal From cb8cf250a5433f9d2b029ef2a6ab8abd39f16419 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 22 Jun 2023 13:54:41 +0200 Subject: [PATCH 3/3] Use php 8.0 for nextcloud 22 --- composer.json | 2 +- composer.lock | 4 ++-- lib/Controller/PageController.php | 5 +---- lib/Db/ReaderEntity.php | 2 +- lib/Hooks.php | 5 +---- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 3bfa30b..cfeca10 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "config": { "platform": { - "php": "7.4" + "php": "8.0" } } } diff --git a/composer.lock b/composer.lock index 9fb3687..7bb4677 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5c7be477b217d6074abc6c2f8d2c2256", + "content-hash": "7b806afecf0b4bd9cf2aed44f533eaf4", "packages": [], "packages-dev": [ { @@ -389,7 +389,7 @@ "platform": [], "platform-dev": [], "platform-overrides": { - "php": "7.4" + "php": "8.0" }, "plugin-api-version": "2.3.0" } diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 2647b81..266a1a4 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -167,10 +167,7 @@ class PageController extends Controller { ]; } - /** - * @param mixed $value - */ - private function toJson($value): string { + private function toJson(array $value): string { return htmlspecialchars(json_encode($value), ENT_QUOTES, 'UTF-8'); } } diff --git a/lib/Db/ReaderEntity.php b/lib/Db/ReaderEntity.php index 6fa301d..66eb48a 100644 --- a/lib/Db/ReaderEntity.php +++ b/lib/Db/ReaderEntity.php @@ -24,7 +24,7 @@ abstract class ReaderEntity extends Entity { * * @return string|array */ - public function conditional_json_decode(string $el) { + public function conditional_json_decode(string $el): mixed { /** @var array $result */ $result = json_decode($el); if (json_last_error() === JSON_ERROR_NONE) { diff --git a/lib/Hooks.php b/lib/Hooks.php index 8ddfe7d..3c99361 100644 --- a/lib/Hooks.php +++ b/lib/Hooks.php @@ -79,10 +79,7 @@ class Hooks { $queryBuilder->executeStatement(); } - /** - * @param mixed $string - */ - private static function isJson($string): bool { + private static function isJson(mixed $string): bool { return is_string($string) && is_array(json_decode($string, true)) && json_last_error() == JSON_ERROR_NONE; } }