Skip to content

Commit ec69c97

Browse files
committed
add 7.4.0.0 sourceGuardian v16 PHP 8
1 parent 82706a8 commit ec69c97

183 files changed

Lines changed: 1304 additions & 380 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
uses: actions/checkout@v4
5757

5858
- name: Run OXID tests
59-
uses: d3datadevelopment/ci-actions/oxid-plugin-test@v1.1.0
59+
uses: d3datadevelopment/ci-actions/oxid-plugin-test@php-tests--v1.1.0
6060
with:
6161
php_version: ${{ matrix.php }}
6262
oxid_ref: ${{ matrix.oxid_ref }}
@@ -72,7 +72,7 @@ jobs:
7272
if: always()
7373
steps:
7474
- name: Report CI status
75-
uses: d3datadevelopment/ci-actions/status-reporter@v1.1.0
75+
uses: d3datadevelopment/ci-actions/status-reporter@status-reporter--v1.0.0
7676
with:
7777
api_status_endpoint: "${{ vars.GITEA_API }}${{ github.sha }}"
7878
auth_token: ${{ secrets.GITEA_TOKEN }}

.php-cs-fixer.php

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

Application/Command/ClearTmp.php

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<?php
2+
3+
/**
4+
* For the full copyright and license information, please view the LICENSE
5+
* file that was distributed with this source code.
6+
*
7+
* https://www.d3data.de
8+
*
9+
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
10+
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
11+
* @link https://www.oxidmodule.com
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace D3\ModCfg\Application\Command;
17+
18+
use Assert\Assert;
19+
use D3\ModCfg\Application\Model\Constants;
20+
use D3\ModCfg\Application\Model\Maintenance\d3clrtmp;
21+
use Exception;
22+
use OxidEsales\Eshop\Core\Registry;
23+
use RuntimeException;
24+
use Symfony\Component\Console\Command\LockableTrait;
25+
use Symfony\Component\Console\Input\InputArgument;
26+
use Symfony\Component\Console\Input\InputInterface;
27+
use Symfony\Component\Console\Output\OutputInterface;
28+
use Symfony\Component\Console\Command\Command;
29+
use Symfony\Component\Stopwatch\Stopwatch;
30+
31+
class ClearTmp extends Command
32+
{
33+
use LockableTrait;
34+
35+
public const COMMAND_TITLE = 'clear tmp folder command';
36+
37+
const ARGUMENT_TYPE = 'type';
38+
39+
const TYPE_ALL = 'all';
40+
const TYPE_TEMPLATES = 'templates';
41+
const TYPE_DATABASE = 'database';
42+
const TYPE_LANGUAGE = 'language';
43+
const TYPE_MENU = 'menu';
44+
const TYPE_CLASSPATH = 'classpath';
45+
const TYPE_STRUCTURE = 'structure';
46+
const TYPE_TAGCLOUD = 'tagcloud';
47+
const TYPE_MODULE = 'module';
48+
const TYPE_SEO = 'seo';
49+
50+
/**
51+
* @codeCoverageIgnore
52+
*/
53+
protected function configure(): void
54+
{
55+
$this
56+
->setName('d3:modcfg:cleartmp')
57+
->setDescription('clear tmp folder')
58+
->setHelp('delete objects from temporary folder')
59+
60+
->addArgument(
61+
self::ARGUMENT_TYPE,
62+
InputArgument::REQUIRED,
63+
sprintf(
64+
'Types of objects to be deleted, possible values are "%1$s"',
65+
$this->getTypeListString()
66+
),
67+
);
68+
}
69+
70+
/**
71+
* @param InputInterface $input
72+
* @param OutputInterface $output
73+
*
74+
* @return int
75+
*/
76+
protected function execute(InputInterface $input, OutputInterface $output): int
77+
{
78+
if ($output->getVerbosity() === OutputInterface::VERBOSITY_QUIET) {
79+
Registry::getSession()->setVariable( 'd3cfgmodcli_quiet', true );
80+
}
81+
82+
$stopWatch = new Stopwatch();
83+
$stopWatch->start(self::COMMAND_TITLE);
84+
85+
$logger = Registry::getLogger();
86+
$logger->notice(self::COMMAND_TITLE, ['status' => 'started']);
87+
88+
if ($this->isLocked()) {
89+
$output->writeln('The command is already running in another process.');
90+
$logger->notice(self::COMMAND_TITLE, ['status' => 'aborted', 'reason' => 'already running']);
91+
return Command::SUCCESS;
92+
}
93+
94+
$output->writeln('Try to clear the tmp folder');
95+
96+
try {
97+
$exitCode = Command::SUCCESS;
98+
$statusMessage = '<info>Successfully finished.</info>';
99+
100+
Assert::that($input->getArgument(self::ARGUMENT_TYPE))
101+
->nullOr()
102+
->inArray($this->getTypeList(), 'Missing or invalid parameters, please check the passed arguments');
103+
104+
$controller = $this->getClearTmp();
105+
call_user_func_array(
106+
[$controller, $this->getTypeMethod($input->getArgument(self::ARGUMENT_TYPE))],
107+
[]
108+
);
109+
} catch (Exception $exception) {
110+
$logger->error(
111+
Constants::OXID_MODULE_ID . ': ' . $exception->getMessage(),
112+
['exception' => $exception]
113+
);
114+
$statusMessage = '<error>Error: ' . $exception->getMessage() . '</error>';
115+
$exitCode = Command::FAILURE;
116+
} finally {
117+
$this->release();
118+
$performance = (string)$stopWatch->stop(self::COMMAND_TITLE);
119+
$logger->notice(self::COMMAND_TITLE, [
120+
'status' => 'finished',
121+
'exit code' => $exitCode,
122+
'performance' => $performance,
123+
]);
124+
$output->writeln($statusMessage . ' ' . ($output->isVerbose() ? $performance : ''));
125+
return $exitCode;
126+
}
127+
}
128+
129+
/**
130+
* @codeCoverageIgnore
131+
*/
132+
protected function isLocked(): bool
133+
{
134+
return !$this->lock();
135+
}
136+
137+
protected function getTypeListString(): string
138+
{
139+
return implode(
140+
", ",
141+
$this->getTypeList()
142+
);
143+
}
144+
145+
protected function getTypeList(): array
146+
{
147+
return [
148+
self::TYPE_ALL,
149+
self::TYPE_TEMPLATES,
150+
self::TYPE_DATABASE,
151+
self::TYPE_LANGUAGE,
152+
self::TYPE_MENU,
153+
self::TYPE_CLASSPATH,
154+
self::TYPE_STRUCTURE,
155+
self::TYPE_TAGCLOUD,
156+
self::TYPE_MODULE,
157+
self::TYPE_SEO,
158+
];
159+
}
160+
161+
protected function getTypeMethod(string $type): string
162+
{
163+
return match ( strtolower( $type ) ) {
164+
self::TYPE_ALL => 'clearAllCache',
165+
self::TYPE_TEMPLATES => 'clearFrontendCache',
166+
self::TYPE_DATABASE => 'clearDataBaseStructCache',
167+
self::TYPE_LANGUAGE => 'clearLangCache',
168+
self::TYPE_MENU => 'clearMenuCache',
169+
self::TYPE_CLASSPATH => 'clearClassPathCache',
170+
self::TYPE_STRUCTURE => 'clearStructureCache',
171+
self::TYPE_TAGCLOUD => 'clearTagcloudCache',
172+
self::TYPE_SEO => 'clearSeoCache',
173+
self::TYPE_MODULE => 'clearModuleCache',
174+
default => throw new RuntimeException('no valid type defined'),
175+
};
176+
}
177+
178+
/**
179+
* @return d3clrtmp
180+
*/
181+
protected function getClearTmp(): d3clrtmp
182+
{
183+
return oxNew( d3clrtmp::class );
184+
}
185+
}

Application/Command/LicenseSet.php

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?php
2+
3+
/**
4+
* For the full copyright and license information, please view the LICENSE
5+
* file that was distributed with this source code.
6+
*
7+
* https://www.d3data.de
8+
*
9+
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
10+
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
11+
* @link https://www.oxidmodule.com
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace D3\ModCfg\Application\Command;
17+
18+
use Assert\Assert;
19+
use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
20+
use D3\ModCfg\Application\Model\Constants;
21+
use Doctrine\DBAL\Driver\Exception as DBALDriveerException;
22+
use Doctrine\DBAL\Exception as DBALException;
23+
use Doctrine\DBAL\Query\QueryBuilder;
24+
use Exception;
25+
use OxidEsales\Eshop\Core\Registry;
26+
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
27+
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
28+
use Psr\Container\ContainerExceptionInterface;
29+
use Psr\Container\NotFoundExceptionInterface;
30+
use Symfony\Component\Console\Command\LockableTrait;
31+
use Symfony\Component\Console\Input\InputArgument;
32+
use Symfony\Component\Console\Input\InputInterface;
33+
use Symfony\Component\Console\Output\OutputInterface;
34+
use Symfony\Component\Console\Command\Command;
35+
use Symfony\Component\Stopwatch\Stopwatch;
36+
37+
class LicenseSet extends Command
38+
{
39+
use LockableTrait;
40+
41+
public const COMMAND_TITLE = 'license key set command';
42+
43+
public const ARGUMENT_SHOPID = 'shop id';
44+
public const ARGUMENT_MODULEID = 'module id';
45+
public const ARGUMENT_LICENSEKEY = 'license key';
46+
47+
/**
48+
* @codeCoverageIgnore
49+
*/
50+
protected function configure(): void
51+
{
52+
$this
53+
->setName('d3:modcfg:license:set')
54+
->setDescription('set license key for D3 modules')
55+
->setHelp('It registers module licences.')
56+
57+
->addArgument(
58+
self::ARGUMENT_SHOPID,
59+
InputArgument::REQUIRED,
60+
sprintf(
61+
'ID of the selected shop, possible values are: "%1$s"',
62+
$this->getShopIdList()
63+
)
64+
)
65+
->addArgument(
66+
self::ARGUMENT_MODULEID,
67+
InputArgument::REQUIRED,
68+
sprintf(
69+
'ID of the module in question, possible values are: "%1$s"',
70+
$this->getModuleIdList()
71+
)
72+
)
73+
->addArgument(
74+
self::ARGUMENT_LICENSEKEY,
75+
InputArgument::REQUIRED,
76+
'license key'
77+
);
78+
}
79+
80+
/**
81+
* @throws ContainerExceptionInterface
82+
* @throws NotFoundExceptionInterface
83+
*/
84+
protected function execute(InputInterface $input, OutputInterface $output): int
85+
{
86+
if ($output->getVerbosity() === OutputInterface::VERBOSITY_QUIET) {
87+
Registry::getSession()->setVariable( 'd3cfgmodcli_quiet', true );
88+
}
89+
90+
$stopWatch = new Stopwatch();
91+
$stopWatch->start(self::COMMAND_TITLE);
92+
93+
$logger = Registry::getLogger();
94+
$logger->notice(self::COMMAND_TITLE, ['status' => 'started']);
95+
96+
if ($this->isLocked()) {
97+
$output->writeln('The command is already running in another process.');
98+
$logger->notice(self::COMMAND_TITLE, ['status' => 'aborted', 'reason' => 'already running']);
99+
return Command::SUCCESS;
100+
}
101+
102+
$output->writeln('Try to set modules license key');
103+
104+
try {
105+
$exitCode = Command::SUCCESS;
106+
$statusMessage = '<info>Successfully finished.</info>';
107+
108+
Assert::that(d3_cfg_mod::isAvailable($input->getArgument(self::ARGUMENT_MODULEID)))->true(
109+
sprintf(
110+
'module id "%1$s" is not available in "%2$s"',
111+
$input->getArgument(self::ARGUMENT_MODULEID),
112+
$this->getModuleIdList()
113+
)
114+
);
115+
116+
$set = oxNew(d3_cfg_mod::class);
117+
$set->setShopId($input->getArgument(self::ARGUMENT_SHOPID));
118+
$set->load($set->getModOxid($input->getArgument(self::ARGUMENT_MODULEID)));
119+
$set->setSerial($input->getArgument(self::ARGUMENT_LICENSEKEY));
120+
$set->save();
121+
} catch (Exception $exception) {
122+
$logger->error(
123+
Constants::OXID_MODULE_ID . ': ' . $exception->getMessage(),
124+
['exception' => $exception]
125+
);
126+
$statusMessage = '<error>Error: ' . $exception->getMessage() . '</error>';
127+
$exitCode = Command::FAILURE;
128+
} finally {
129+
$this->release();
130+
$performance = (string)$stopWatch->stop(self::COMMAND_TITLE);
131+
$logger->notice(self::COMMAND_TITLE, [
132+
'status' => 'finished',
133+
'exit code' => $exitCode,
134+
'performance' => $performance,
135+
]);
136+
$output->writeln($statusMessage . ' ' . ($output->isVerbose() ? $performance : ''));
137+
return $exitCode;
138+
}
139+
}
140+
141+
/**
142+
* @codeCoverageIgnore
143+
*/
144+
protected function isLocked(): bool
145+
{
146+
return !$this->lock();
147+
}
148+
149+
protected function getShopIdList(): string
150+
{
151+
$config = Registry::getConfig();
152+
return implode(
153+
', ',
154+
$config->getShopIds()
155+
);
156+
}
157+
158+
protected function getModuleIdList(): string
159+
{
160+
try {
161+
/** @var QueryBuilder $oQB */
162+
$oQB = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
163+
$oQB->select('DISTINCT oxmodid')->from(oxNew(d3_cfg_mod::class)->getCoreTableName());
164+
$idList = array_keys($oQB->execute()->fetchAllAssociativeIndexed());
165+
166+
return implode(
167+
", ",
168+
$idList
169+
);
170+
} catch (DBALException|DBALDriveerException) {
171+
return '';
172+
}
173+
}
174+
}

0 commit comments

Comments
 (0)