From b65c9c00f54f0498fa5547eb52160c6950943fc6 Mon Sep 17 00:00:00 2001 From: Sascha Heilmeier Date: Thu, 12 Jun 2025 16:11:06 +0200 Subject: [PATCH 1/2] feat: add frosh:es:delete-unused-indices --- src/Command/DeleteUnusedIndicesCommand.php | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Command/DeleteUnusedIndicesCommand.php diff --git a/src/Command/DeleteUnusedIndicesCommand.php b/src/Command/DeleteUnusedIndicesCommand.php new file mode 100644 index 00000000..7006b565 --- /dev/null +++ b/src/Command/DeleteUnusedIndicesCommand.php @@ -0,0 +1,28 @@ +elasticsearchManager->deleteUnusedIndices(); + + return Command::SUCCESS; + } +} \ No newline at end of file From 8e1dbc6ad39769a4137ce2c4d09ee745cbf66fdf Mon Sep 17 00:00:00 2001 From: Felix Schneider Date: Thu, 12 Jun 2025 20:10:53 +0200 Subject: [PATCH 2/2] style: fix issues reported by linter --- src/Command/DeleteUnusedIndicesCommand.php | 2 +- src/Command/DevRobotsTxtCommand.php | 4 +++ .../ExtensionChecksumCreateCommand.php | 1 + src/Components/CacheHelper.php | 3 ++ src/Controller/ShopwareFilesController.php | 1 + .../module/frosh-tools/page/index/index.js | 33 +++++++++---------- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Command/DeleteUnusedIndicesCommand.php b/src/Command/DeleteUnusedIndicesCommand.php index 7006b565..92ca5c1e 100644 --- a/src/Command/DeleteUnusedIndicesCommand.php +++ b/src/Command/DeleteUnusedIndicesCommand.php @@ -25,4 +25,4 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::SUCCESS; } -} \ No newline at end of file +} diff --git a/src/Command/DevRobotsTxtCommand.php b/src/Command/DevRobotsTxtCommand.php index f6e58b7c..c8da01e0 100644 --- a/src/Command/DevRobotsTxtCommand.php +++ b/src/Command/DevRobotsTxtCommand.php @@ -50,6 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return self::SUCCESS; } + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ $robotsFile = fopen($robotsPath, 'wb'); \assert($robotsFile !== false); @@ -72,6 +73,7 @@ private function revertToOriginal(InputInterface $input, OutputInterface $output // If only input from command is present if ($file === $createdString) { + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ unlink($robotsPath); $io->success('robots.txt file deleted :)'); @@ -81,6 +83,7 @@ private function revertToOriginal(InputInterface $input, OutputInterface $output // removes everything between #soc & #eoc $content = preg_replace('/#soc[\s\S]+?#eoc/', '', $file); + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ file_put_contents($robotsPath, $content); $io->success('robots.txt reverted to original :)'); @@ -103,6 +106,7 @@ private function changeRobotsTxt(InputInterface $input, OutputInterface $output, } $content = "#soc\nUser-agent: *\nDisallow: /\n#eoc\n" . $file; + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ file_put_contents($robotsPath, $content); $io->success('robots.txt changed :)'); diff --git a/src/Command/ExtensionChecksumCreateCommand.php b/src/Command/ExtensionChecksumCreateCommand.php index 7fea02dd..dc3da268 100644 --- a/src/Command/ExtensionChecksumCreateCommand.php +++ b/src/Command/ExtensionChecksumCreateCommand.php @@ -80,6 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return self::FAILURE; } + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ if (file_put_contents($checksumFilePath, \json_encode($checksumStruct->jsonSerialize(), \JSON_THROW_ON_ERROR)) === false) { $io->error(\sprintf('Failed to write to file "%s"', $checksumFilePath)); diff --git a/src/Components/CacheHelper.php b/src/Components/CacheHelper.php index 120a71b2..fdf312d1 100644 --- a/src/Components/CacheHelper.php +++ b/src/Components/CacheHelper.php @@ -22,6 +22,7 @@ public static function removeDir(string $path): void { // If the given path is a file if (is_file($path)) { + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ unlink($path); return; @@ -30,6 +31,7 @@ public static function removeDir(string $path): void if (self::rsyncAvailable()) { $blankDir = sys_get_temp_dir() . '/' . uniqid() . '/'; + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ if (!mkdir($blankDir, 0o755, true) && !is_dir($blankDir)) { throw new \RuntimeException(\sprintf('Directory "%s" was not created', $blankDir)); } @@ -41,6 +43,7 @@ public static function removeDir(string $path): void throw new CannotClearCacheException($process->getErrorOutput()); } + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ rmdir($blankDir); } else { $process = new Process(['find', $path . '/', '-delete']); diff --git a/src/Controller/ShopwareFilesController.php b/src/Controller/ShopwareFilesController.php index b8ae0a21..2c2c684f 100644 --- a/src/Controller/ShopwareFilesController.php +++ b/src/Controller/ShopwareFilesController.php @@ -164,6 +164,7 @@ public function restoreShopwareFile(Request $request, Context $context): JsonRes return new JsonResponse(['error' => 'File would be empty!']); } + /** @phpstan-ignore shopware.forbidLocalDiskWrite */ file_put_contents($path, $content); if (\function_exists('opcache_reset')) { diff --git a/src/Resources/app/administration/src/module/frosh-tools/page/index/index.js b/src/Resources/app/administration/src/module/frosh-tools/page/index/index.js index 7a63f66a..cba8fb63 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/page/index/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/page/index/index.js @@ -1,24 +1,23 @@ import './frosh-tools.scss'; import template from './template.twig'; -const {Component} = Shopware; +const { Component } = Shopware; Component.register('frosh-tools-index', { - template, - computed: { - elasticsearchAvailable() { - try { - return ( - Shopware.Store.get('context').app.config.settings - ?.elasticsearchEnabled || false - ); - - } catch { - return ( - Shopware.State.get('context').app.config.settings - ?.elasticsearchEnabled || false - ); - } + template, + computed: { + elasticsearchAvailable() { + try { + return ( + Shopware.Store.get('context').app.config.settings + ?.elasticsearchEnabled || false + ); + } catch { + return ( + Shopware.State.get('context').app.config.settings + ?.elasticsearchEnabled || false + ); + } + }, }, - }, });