Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Command/DeleteUnusedIndicesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Frosh\Tools\Command;

use Frosh\Tools\Components\Elasticsearch\ElasticsearchManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand('frosh:es:delete-unused-indices', 'Deletes unused Elasticsearch indices')]
class DeleteUnusedIndicesCommand extends Command
{
public function __construct(
private readonly ElasticsearchManager $elasticsearchManager,
) {
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->elasticsearchManager->deleteUnusedIndices();

return Command::SUCCESS;
}
}
4 changes: 4 additions & 0 deletions src/Command/DevRobotsTxtCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 :)');

Expand All @@ -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 :)');

Expand All @@ -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 :)');
Expand Down
1 change: 1 addition & 0 deletions src/Command/ExtensionChecksumCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
3 changes: 3 additions & 0 deletions src/Components/CacheHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
Expand All @@ -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']);
Expand Down
1 change: 1 addition & 0 deletions src/Controller/ShopwareFilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
);
}
},
},
},
});