From 9074ce10393731a62615c98e9379d6fe3cac4630 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 17:04:16 +0300 Subject: [PATCH 1/9] do not spam error into log file in getExAppFileAction, getExAppMenuEntry --- lib/Service/ExFilesActionsMenuService.php | 5 ++--- lib/Service/TopMenuService.php | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Service/ExFilesActionsMenuService.php b/lib/Service/ExFilesActionsMenuService.php index edab9d37..9aaf6e96 100644 --- a/lib/Service/ExFilesActionsMenuService.php +++ b/lib/Service/ExFilesActionsMenuService.php @@ -120,11 +120,10 @@ public function getExAppFileAction(string $appId, string $fileActionName): ?ExFi try { $fileAction = $this->mapper->findByAppIdName($appId, $fileActionName); - $this->cache->set($cacheKey, $fileAction); } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { - $this->logger->error(sprintf('ExApp %s FileAction %s not found. Error: %s', $appId, $fileActionName, $e->getMessage()), ['exception' => $e]); - $fileAction = null; + return null; } + $this->cache->set($cacheKey, $fileAction); return $fileAction; } diff --git a/lib/Service/TopMenuService.php b/lib/Service/TopMenuService.php index b9186d56..2f03268d 100644 --- a/lib/Service/TopMenuService.php +++ b/lib/Service/TopMenuService.php @@ -135,11 +135,10 @@ public function getExAppMenuEntry(string $appId, string $name): ?TopMenu { try { $menuEntry = $this->mapper->findByAppIdName($appId, $name); - $this->cache->set($cacheKey, $menuEntry); } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { - $this->logger->error($e->getMessage()); return null; } + $this->cache->set($cacheKey, $menuEntry); return $menuEntry; } From 4d19f803f771d70ef7bbdaf69d607595c9d413ee Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 17:36:25 +0300 Subject: [PATCH 2/9] add test on Oracle --- .github/workflows/tests.yml | 114 +++++++++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5544d0d9..2932706a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -254,11 +254,123 @@ jobs: path: data/nextcloud.log if-no-files-found: warn + nc-py-api-oci: + runs-on: ubuntu-22.04 + name: NC_Py_API • stable28 • 8.2 • Oracle + + services: + oracle: + image: ghcr.io/gvenzl/oracle-xe:11 + env: + ORACLE_RANDOM_PASSWORD: true + APP_USER: useroracle + APP_USER_PASSWORD: userpassword + options: >- + --health-cmd healthcheck.sh + --health-interval 10s + --health-timeout 5s + --health-retries 10 + ports: + - 1521:1521/tcp + + steps: + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Set app env + run: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV + + - name: Checkout server + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: true + repository: nextcloud/server + ref: stable28 + + - name: Checkout Notifications + uses: actions/checkout@v3 + with: + repository: nextcloud/notifications + ref: stable28 + path: apps/notifications + + - name: Checkout AppAPI + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + path: apps/${{ env.APP_NAME }} + + - name: Set up php + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, \ + posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, oci8 + + - name: Check composer file existence + id: check_composer + uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 + with: + files: apps/${{ env.APP_NAME }}/composer.json + + - name: Set up dependencies + if: steps.check_composer.outputs.files_exists == 'true' + working-directory: apps/${{ env.APP_NAME }} + run: composer i + + - name: Set up Nextcloud + env: + DB_PORT: 4444 + run: | + mkdir data + ./occ maintenance:install --verbose --database=oci --database-name=XE \ + --database-host=127.0.0.1 --database-port=1521 --database-user=useroracle --database-pass=userpassword \ + --admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }} + ./occ app:enable --force ${{ env.APP_NAME }} + ./occ app:enable notifications + ./occ app:enable --force ${{ env.APP_NAME }} + + - name: Run Nextcloud + run: PHP_CLI_SERVER_WORKERS=2 php -S 127.0.0.1:8080 & + + - name: Checkout NcPyApi + uses: actions/checkout@v3 + with: + path: nc_py_api + repository: cloud-py-api/nc_py_api + + - name: Install NcPyApi + working-directory: nc_py_api + run: python3 -m pip -v install ".[dev]" + + - name: Register NcPyApi + run: | + cd nc_py_api + python3 tests/_install.py & + echo $! > /tmp/_install.pid + python3 tests/_install_wait.py http://127.0.0.1:$APP_PORT/heartbeat "\"status\":\"ok\"" 15 0.5 + cd .. + sh nc_py_api/scripts/ci_register.sh "$APP_ID" "$APP_VERSION" "$APP_SECRET" "localhost" "$APP_PORT" + kill -15 $(cat /tmp/_install.pid) + timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null + + - name: Run NC_Py_API tests + working-directory: nc_py_api + run: python3 -m pytest + + - name: Upload NC logs + if: always() + uses: actions/upload-artifact@v3 + with: + name: oci_nc_py_api_stable28_8.2_nextcloud.log + path: data/nextcloud.log + if-no-files-found: warn + tests-success: permissions: contents: none runs-on: ubuntu-22.04 - needs: [nc-py-api-pgsql, nc-py-api-mysql] + needs: [nc-py-api-pgsql, nc-py-api-mysql, nc-py-api-oci] name: Tests-OK steps: - run: echo "Tests passed successfully" From ec9e112540fce9b37389deac202d3b65a754253a Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 17:40:27 +0300 Subject: [PATCH 3/9] fixed typo from previous commit --- .github/workflows/tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2932706a..4e5d5dc8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -213,7 +213,9 @@ jobs: DB_PORT: 4444 run: | mkdir data - ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud \ + --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword \ + --admin-user admin --admin-pass admin ./occ app:enable --force ${{ env.APP_NAME }} ./occ app:enable notifications ./occ app:enable --force ${{ env.APP_NAME }} @@ -325,7 +327,7 @@ jobs: mkdir data ./occ maintenance:install --verbose --database=oci --database-name=XE \ --database-host=127.0.0.1 --database-port=1521 --database-user=useroracle --database-pass=userpassword \ - --admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }} + --admin-user admin --admin-pass admin ./occ app:enable --force ${{ env.APP_NAME }} ./occ app:enable notifications ./occ app:enable --force ${{ env.APP_NAME }} From 938d555448b882f427ee8676462cd8cb7478e2aa Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 19:49:29 +0300 Subject: [PATCH 4/9] OCI: ORA-01400: cannot insert NULL into "ex_apps_ui_top_menu.icon_url" (1) --- lib/Migration/Version1003Date202311061844.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Migration/Version1003Date202311061844.php b/lib/Migration/Version1003Date202311061844.php index 8b557d25..5fb73d43 100644 --- a/lib/Migration/Version1003Date202311061844.php +++ b/lib/Migration/Version1003Date202311061844.php @@ -42,7 +42,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'length' => 32, ]); $table->addColumn('icon_url', Types::STRING, [ - 'notnull' => true, + 'notnull' => false, 'default' => '', ]); $table->addColumn('admin_required', Types::SMALLINT, [ From a678fb0362637e333ab3865485fd15b5fe44bc4f Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 19:56:47 +0300 Subject: [PATCH 5/9] OCI: ORA-01400: cannot insert NULL into "ex_apps_ui_top_menu.icon_url" (2) --- lib/Db/UI/TopMenu.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Db/UI/TopMenu.php b/lib/Db/UI/TopMenu.php index b71d771c..8b9c6062 100644 --- a/lib/Db/UI/TopMenu.php +++ b/lib/Db/UI/TopMenu.php @@ -54,6 +54,8 @@ public function __construct(array $params = []) { } if (isset($params['icon_url'])) { $this->setIconUrl($params['icon_url']); + } else { + $this->setIconUrl(''); } if (isset($params['admin_required'])) { $this->setAdminRequired($params['admin_required']); From 2f0ba2f415a3beae149def2bc0079ab45f051b29 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 20:11:50 +0300 Subject: [PATCH 6/9] reverted previous commit --- lib/Db/UI/TopMenu.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Db/UI/TopMenu.php b/lib/Db/UI/TopMenu.php index 8b9c6062..b71d771c 100644 --- a/lib/Db/UI/TopMenu.php +++ b/lib/Db/UI/TopMenu.php @@ -54,8 +54,6 @@ public function __construct(array $params = []) { } if (isset($params['icon_url'])) { $this->setIconUrl($params['icon_url']); - } else { - $this->setIconUrl(''); } if (isset($params['admin_required'])) { $this->setAdminRequired($params['admin_required']); From 63fd24d80627578fd0a86f0e02862ba0888dd5cd Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 21:10:55 +0300 Subject: [PATCH 7/9] UI: DB: file_actions: "icon" can be null (OCI) --- .../FilesActionsMenu.php} | 4 +-- .../FilesActionsMenuMapper.php} | 18 +++++------ lib/Migration/Version1000Date202305221555.php | 2 +- lib/Service/ExFilesActionsMenuService.php | 31 +++++++++---------- 4 files changed, 27 insertions(+), 28 deletions(-) rename lib/Db/{ExFilesActionsMenu.php => UI/FilesActionsMenu.php} (96%) rename lib/Db/{ExFilesActionsMenuMapper.php => UI/FilesActionsMenuMapper.php} (87%) diff --git a/lib/Db/ExFilesActionsMenu.php b/lib/Db/UI/FilesActionsMenu.php similarity index 96% rename from lib/Db/ExFilesActionsMenu.php rename to lib/Db/UI/FilesActionsMenu.php index e9b32cac..825301d3 100644 --- a/lib/Db/ExFilesActionsMenu.php +++ b/lib/Db/UI/FilesActionsMenu.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace OCA\AppAPI\Db; +namespace OCA\AppAPI\Db\UI; use JsonSerializable; use OCP\AppFramework\Db\Entity; @@ -31,7 +31,7 @@ * @method void setIconClass(string $iconClass) * @method void setActionHandler(string $actionHandler) */ -class ExFilesActionsMenu extends Entity implements JsonSerializable { +class FilesActionsMenu extends Entity implements JsonSerializable { protected $appid; protected $name; protected $displayName; diff --git a/lib/Db/ExFilesActionsMenuMapper.php b/lib/Db/UI/FilesActionsMenuMapper.php similarity index 87% rename from lib/Db/ExFilesActionsMenuMapper.php rename to lib/Db/UI/FilesActionsMenuMapper.php index b9831784..35c26be5 100644 --- a/lib/Db/ExFilesActionsMenuMapper.php +++ b/lib/Db/UI/FilesActionsMenuMapper.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace OCA\AppAPI\Db; +namespace OCA\AppAPI\Db\UI; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; @@ -12,9 +12,9 @@ use OCP\IDBConnection; /** - * @template-extends QBMapper + * @template-extends QBMapper */ -class ExFilesActionsMenuMapper extends QBMapper { +class FilesActionsMenuMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'ex_files_actions_menu'); } @@ -48,13 +48,13 @@ public function findAllEnabled(): array { * @param string $appId * @param string $name * - * @throws MultipleObjectsReturnedException if more than one result + * @return FilesActionsMenu * @throws DoesNotExistException if not found * @throws Exception * - * @return ExFilesActionsMenu + * @throws MultipleObjectsReturnedException if more than one result */ - public function findByAppidName(string $appId, string $name): ExFilesActionsMenu { + public function findByAppidName(string $appId, string $name): FilesActionsMenu { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->tableName) @@ -69,13 +69,13 @@ public function findByAppidName(string $appId, string $name): ExFilesActionsMenu * @param string $name * * - * @throws MultipleObjectsReturnedException if more than one result + * @return FilesActionsMenu * @throws DoesNotExistException|Exception if not found * @throws Exception * - * @return ExFilesActionsMenu + * @throws MultipleObjectsReturnedException if more than one result */ - public function findByName(string $name): ExFilesActionsMenu { + public function findByName(string $name): FilesActionsMenu { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->tableName) diff --git a/lib/Migration/Version1000Date202305221555.php b/lib/Migration/Version1000Date202305221555.php index b0b23f83..952bae67 100644 --- a/lib/Migration/Version1000Date202305221555.php +++ b/lib/Migration/Version1000Date202305221555.php @@ -207,7 +207,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'default' => 0, ]); $table->addColumn('icon', Types::STRING, [ - 'notnull' => true, + 'notnull' => false, 'default' => '', ]); $table->addColumn('icon_class', Types::STRING, [ diff --git a/lib/Service/ExFilesActionsMenuService.php b/lib/Service/ExFilesActionsMenuService.php index 9aaf6e96..1616406d 100644 --- a/lib/Service/ExFilesActionsMenuService.php +++ b/lib/Service/ExFilesActionsMenuService.php @@ -5,10 +5,9 @@ namespace OCA\AppAPI\Service; use OCA\AppAPI\AppInfo\Application; -use OCA\AppAPI\Db\ExFilesActionsMenu; -use OCA\AppAPI\Db\ExFilesActionsMenuMapper; +use OCA\AppAPI\Db\UI\FilesActionsMenu; +use OCA\AppAPI\Db\UI\FilesActionsMenuMapper; use OCP\AppFramework\Db\DoesNotExistException; - use OCP\AppFramework\Db\MultipleObjectsReturnedException; use OCP\AppFramework\Http; use OCP\DB\Exception; @@ -24,10 +23,10 @@ class ExFilesActionsMenuService { private IClient $client; public function __construct( - ICacheFactory $cacheFactory, - private readonly ExFilesActionsMenuMapper $mapper, - private readonly LoggerInterface $logger, - IClientService $clientService, + ICacheFactory $cacheFactory, + private readonly FilesActionsMenuMapper $mapper, + private readonly LoggerInterface $logger, + IClientService $clientService, ) { $this->cache = $cacheFactory->createDistributed(Application::APP_ID . '/ex_files_actions_menu'); $this->client = $clientService->newClient(); @@ -39,16 +38,16 @@ public function __construct( * @param string $appId * @param array $params * - * @return ExFilesActionsMenu|null + * @return FilesActionsMenu|null */ - public function registerFileActionMenu(string $appId, array $params): ?ExFilesActionsMenu { + public function registerFileActionMenu(string $appId, array $params): ?FilesActionsMenu { try { $fileActionMenu = $this->mapper->findByName($params['name']); } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception) { $fileActionMenu = null; } try { - $newFileActionMenu = new ExFilesActionsMenu([ + $newFileActionMenu = new FilesActionsMenu([ 'appid' => $appId, 'name' => $params['name'], 'display_name' => $params['display_name'], @@ -72,7 +71,7 @@ public function registerFileActionMenu(string $appId, array $params): ?ExFilesAc return $fileActionMenu; } - public function unregisterFileActionMenu(string $appId, string $fileActionMenuName): ?ExFilesActionsMenu { + public function unregisterFileActionMenu(string $appId, string $fileActionMenuName): ?FilesActionsMenu { try { $fileActionMenu = $this->getExAppFileAction($appId, $fileActionMenuName); if ($fileActionMenu === null) { @@ -91,7 +90,7 @@ public function unregisterFileActionMenu(string $appId, string $fileActionMenuNa /** * Get list of registered file actions (only for enabled ExApps) * - * @return ExFilesActionsMenu[]|null + * @return FilesActionsMenu[]|null */ public function getRegisteredFileActions(): ?array { try { @@ -99,7 +98,7 @@ public function getRegisteredFileActions(): ?array { $cached = $this->cache->get($cacheKey); if ($cached !== null) { return array_map(function ($cacheEntry) { - return $cacheEntry instanceof ExFilesActionsMenu ? $cacheEntry : new ExFilesActionsMenu($cacheEntry); + return $cacheEntry instanceof FilesActionsMenu ? $cacheEntry : new FilesActionsMenu($cacheEntry); }, $cached); } @@ -111,16 +110,16 @@ public function getRegisteredFileActions(): ?array { } } - public function getExAppFileAction(string $appId, string $fileActionName): ?ExFilesActionsMenu { + public function getExAppFileAction(string $appId, string $fileActionName): ?FilesActionsMenu { $cacheKey = '/ex_files_actions_menu_' . $appId . '_' . $fileActionName; $cache = $this->cache->get($cacheKey); if ($cache !== null) { - return $cache instanceof ExFilesActionsMenu ? $cache : new ExFilesActionsMenu($cache); + return $cache instanceof FilesActionsMenu ? $cache : new FilesActionsMenu($cache); } try { $fileAction = $this->mapper->findByAppIdName($appId, $fileActionName); - } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception) { return null; } $this->cache->set($cacheKey, $fileAction); From 78ed8c0727b998ccfa0658d477f3e590cc1ca192 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 21:57:30 +0300 Subject: [PATCH 8/9] UI: DB: top_menu.iconUrl -> top_menu.icon --- lib/Controller/OCSUiController.php | 4 ++-- lib/Db/UI/TopMenu.php | 14 +++++++------- lib/Db/UI/TopMenuMapper.php | 2 +- lib/Migration/Version1003Date202311061844.php | 3 ++- lib/Service/TopMenuService.php | 12 ++++++------ 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/Controller/OCSUiController.php b/lib/Controller/OCSUiController.php index c223e061..aa4ba4f8 100644 --- a/lib/Controller/OCSUiController.php +++ b/lib/Controller/OCSUiController.php @@ -115,9 +115,9 @@ public function getFileActionMenu(string $name): DataResponse { #[NoCSRFRequired] public function registerExAppMenuEntry( string $name, string $displayName, - string $iconUrl = '', int $adminRequired = 0): DataResponse { + string $icon = '', int $adminRequired = 0): DataResponse { $result = $this->menuEntryService->registerExAppMenuEntry( - $this->request->getHeader('EX-APP-ID'), $name, $displayName, $iconUrl, $adminRequired); + $this->request->getHeader('EX-APP-ID'), $name, $displayName, $icon, $adminRequired); if (!$result) { throw new OCSBadRequestException("Top Menu entry could not be registered"); } diff --git a/lib/Db/UI/TopMenu.php b/lib/Db/UI/TopMenu.php index b71d771c..6b16fbce 100644 --- a/lib/Db/UI/TopMenu.php +++ b/lib/Db/UI/TopMenu.php @@ -15,19 +15,19 @@ * @method string getAppid() * @method string getName() * @method string getDisplayName() - * @method string getIconUrl() + * @method string getIcon() * @method int getAdminRequired() * @method void setAppid(string $appid) * @method void setName(string $name) * @method void setDisplayName(string $displayName) - * @method void setIconUrl(string $iconUrl) + * @method void setIcon(string $icon) * @method void setAdminRequired(int $adminRequired) */ class TopMenu extends Entity implements JsonSerializable { protected $appid; protected $name; protected $displayName; - protected $iconUrl; + protected $icon; protected $adminRequired; /** @@ -37,7 +37,7 @@ public function __construct(array $params = []) { $this->addType('appid', 'string'); $this->addType('name', 'string'); $this->addType('display_name', 'string'); - $this->addType('icon_url', 'string'); + $this->addType('icon', 'string'); $this->addType('admin_required', 'integer'); if (isset($params['id'])) { @@ -52,8 +52,8 @@ public function __construct(array $params = []) { if (isset($params['display_name'])) { $this->setDisplayName($params['display_name']); } - if (isset($params['icon_url'])) { - $this->setIconUrl($params['icon_url']); + if (isset($params['icon'])) { + $this->setIcon($params['icon']); } if (isset($params['admin_required'])) { $this->setAdminRequired($params['admin_required']); @@ -66,7 +66,7 @@ public function jsonSerialize(): array { 'appid' => $this->getAppid(), 'name' => $this->getName(), 'display_name' => $this->getDisplayName(), - 'icon_url' => $this->getIconUrl(), + 'icon' => $this->getIcon(), 'admin_required' => $this->getAdminRequired(), ]; } diff --git a/lib/Db/UI/TopMenuMapper.php b/lib/Db/UI/TopMenuMapper.php index 5eb12177..d5987989 100644 --- a/lib/Db/UI/TopMenuMapper.php +++ b/lib/Db/UI/TopMenuMapper.php @@ -28,7 +28,7 @@ public function findAllEnabled(): array { 'menu_entries.appid', 'menu_entries.name', 'menu_entries.display_name', - 'menu_entries.icon_url', + 'menu_entries.icon', 'menu_entries.admin_required', ) ->from($this->tableName, 'menu_entries') diff --git a/lib/Migration/Version1003Date202311061844.php b/lib/Migration/Version1003Date202311061844.php index 5fb73d43..dd92e170 100644 --- a/lib/Migration/Version1003Date202311061844.php +++ b/lib/Migration/Version1003Date202311061844.php @@ -41,13 +41,14 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'notnull' => true, 'length' => 32, ]); - $table->addColumn('icon_url', Types::STRING, [ + $table->addColumn('icon', Types::STRING, [ 'notnull' => false, 'default' => '', ]); $table->addColumn('admin_required', Types::SMALLINT, [ 'notnull' => true, 'default' => 0, + 'length' => 1, ]); $table->setPrimaryKey(['id']); diff --git a/lib/Service/TopMenuService.php b/lib/Service/TopMenuService.php index 2f03268d..b8322354 100644 --- a/lib/Service/TopMenuService.php +++ b/lib/Service/TopMenuService.php @@ -57,7 +57,7 @@ public function registerMenuEntries(ContainerInterface $container): void { $urlGenerator = $container->get(IURLGenerator::class); $appId = $menuEntry->getAppid(); $entryName = $menuEntry->getName(); - $iconUrl = $menuEntry->getIconUrl(); + $icon= $menuEntry->getIcon(); return [ 'id' => Application::APP_ID . '_' . $appId . '_' . $entryName, 'type' => 'link', @@ -65,10 +65,10 @@ public function registerMenuEntries(ContainerInterface $container): void { 'href' => $urlGenerator->linkToRoute( 'app_api.TopMenu.viewExAppPage', ['appId' => $appId, 'name' => $entryName] ), - 'icon' => $iconUrl === '' ? + 'icon' => $icon === '' ? $urlGenerator->imagePath('app_api', 'app.svg') : $urlGenerator->linkToRoute( - 'app_api.ExAppProxy.ExAppGet', ['appId' => $appId, 'other' => $iconUrl] + 'app_api.ExAppProxy.ExAppGet', ['appId' => $appId, 'other' => $icon] ), 'name' => $menuEntry->getDisplayName(), ]; @@ -77,14 +77,14 @@ public function registerMenuEntries(ContainerInterface $container): void { } public function registerExAppMenuEntry(string $appId, string $name, string $displayName, - string $iconUrl, int $adminRequired): ?TopMenu { + string $icon, int $adminRequired): ?TopMenu { $menuEntry = $this->getExAppMenuEntry($appId, $name); try { $newMenuEntry = new TopMenu([ 'appid' => $appId, 'name' => $name, 'display_name' => $displayName, - 'icon_url' => $iconUrl, + 'icon' => $icon, 'admin_required' => $adminRequired, ]); if ($menuEntry !== null) { @@ -135,7 +135,7 @@ public function getExAppMenuEntry(string $appId, string $name): ?TopMenu { try { $menuEntry = $this->mapper->findByAppIdName($appId, $name); - } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception) { return null; } $this->cache->set($cacheKey, $menuEntry); From 37a3eb0dcc03cf14d9b35eb43120508776057ec0 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 3 Dec 2023 22:18:40 +0300 Subject: [PATCH 9/9] composer cs:fix --- lib/Db/UI/TopMenu.php | 2 +- lib/Service/TopMenuService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Db/UI/TopMenu.php b/lib/Db/UI/TopMenu.php index 6b16fbce..987a1410 100644 --- a/lib/Db/UI/TopMenu.php +++ b/lib/Db/UI/TopMenu.php @@ -38,7 +38,7 @@ public function __construct(array $params = []) { $this->addType('name', 'string'); $this->addType('display_name', 'string'); $this->addType('icon', 'string'); - $this->addType('admin_required', 'integer'); + $this->addType('admin_required', 'int'); if (isset($params['id'])) { $this->setId($params['id']); diff --git a/lib/Service/TopMenuService.php b/lib/Service/TopMenuService.php index b8322354..3075dc8b 100644 --- a/lib/Service/TopMenuService.php +++ b/lib/Service/TopMenuService.php @@ -57,7 +57,7 @@ public function registerMenuEntries(ContainerInterface $container): void { $urlGenerator = $container->get(IURLGenerator::class); $appId = $menuEntry->getAppid(); $entryName = $menuEntry->getName(); - $icon= $menuEntry->getIcon(); + $icon = $menuEntry->getIcon(); return [ 'id' => Application::APP_ID . '_' . $appId . '_' . $entryName, 'type' => 'link',