Skip to content

Commit c7c2c2f

Browse files
feat: 6.7 compability (#45)
--------- Co-authored-by: Oliver Skroblin <[email protected]>
1 parent cf35044 commit c7c2c2f

9 files changed

+51
-11
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
allowEol: false
3131
justMinMaxShopware: true
3232
allowShopwareNext: true
33-
allowShopwareRC: false
33+
allowShopwareRC: true
3434
test:
3535
env:
3636
PLUGIN_NAME: TinectRedirects

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
"name": "Tinect"
1010
}
1111
],
12+
"minimum-stability": "RC",
1213
"require": {
13-
"shopware/core": "~6.6.0"
14+
"shopware/core": "~6.6.0||~6.7.0"
1415
},
1516
"extra": {
1617
"shopware-plugin-class": "Tinect\\Redirects\\TinectRedirects",

src/Command/CleanupExcludesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9292
return Command::SUCCESS;
9393
}
9494

95-
if ($input->getOption('dry-run')) {
95+
if ($input->getOption('dry-run') === true) {
9696
$output->writeln('Would delete ' . $countDeletes . ' entries');
9797
} else {
9898
$output->writeln('Deleting ' . $countDeletes . ' entries:');

src/Extension/SalesChannelDomainExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public function getDefinitionClass(): string
3030
{
3131
return SalesChannelDomainDefinition::class;
3232
}
33+
34+
public function getEntityName(): string
35+
{
36+
return 'sales_channel_domain';
37+
}
3338
}

src/Migration/Migration1615031757ImportExportProfile.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ public function update(Connection $connection): void
2828
$profile['mapping'] = json_encode($profile['mapping'], \JSON_THROW_ON_ERROR);
2929
$profile['created_at'] = (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT);
3030

31+
$name = $profile['name'];
32+
unset($profile['name']);
33+
3134
$connection->insert('import_export_profile', $profile);
3235

3336
$translation = [
3437
'import_export_profile_id' => $profile['id'],
3538
'language_id' => Uuid::fromHexToBytes(Defaults::LANGUAGE_SYSTEM),
36-
'label' => $profile['name'],
39+
'label' => $name,
3740
'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
3841
];
3942
$connection->insert('import_export_profile_translation', $translation);
@@ -58,6 +61,7 @@ private function getProfiles(): array
5861
[
5962
'name' => 'Default redirect',
6063
'source_entity' => RedirectDefinition::ENTITY_NAME,
64+
'technical_name' => 'default_' . RedirectDefinition::ENTITY_NAME,
6165
'mapping' => [
6266
['key' => 'id', 'mappedKey' => 'id'],
6367
['key' => 'httpCode', 'mappedKey' => 'http_code'],

src/Migration/Migration1720360485AddExcludes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function update(Connection $connection): void
2222
['configurationKey' => 'TinectRedirects.config.excludes']
2323
)->fetchAllAssociative();
2424

25-
if (empty($existingExcludes)) {
25+
if ($existingExcludes === []) {
2626
return;
2727
}
2828

@@ -33,7 +33,7 @@ public function update(Connection $connection): void
3333

3434
$configurationValue = json_decode($existingExclude['configuration_value'], true, 512, JSON_THROW_ON_ERROR);
3535

36-
if (!\is_array($configurationValue) || !isset($configurationValue['_value'])) {
36+
if (!\is_array($configurationValue) || !isset($configurationValue['_value']) || !\is_string($configurationValue['_value'])) {
3737
continue;
3838
}
3939

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tinect\Redirects\Migration;
6+
7+
use Doctrine\DBAL\Connection;
8+
use Shopware\Core\Framework\Migration\MigrationStep;
9+
use Tinect\Redirects\Content\Redirect\RedirectDefinition;
10+
11+
class Migration1738788990ImportExportTechnicalName extends MigrationStep
12+
{
13+
public function getCreationTimestamp(): int
14+
{
15+
return 1738788990;
16+
}
17+
18+
public function update(Connection $connection): void
19+
{
20+
$connection->executeStatement(
21+
'UPDATE import_export_profile SET technical_name = :technicalName WHERE source_entity = :sourceEntity',
22+
[
23+
'technicalName' => 'default_' . RedirectDefinition::ENTITY_NAME,
24+
'sourceEntity' => RedirectDefinition::ENTITY_NAME,
25+
]
26+
);
27+
}
28+
}

src/Subscriber/BeforeSendResponseSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private function handleRequest(Request $request): ?Response
133133

134134
$targetURL = $this->seoUrlPlaceholderHandler->replace($targetURL, $host, $salesChannelContext);
135135

136-
if (!parse_url($targetURL, PHP_URL_SCHEME)) {
136+
if (\in_array(\parse_url($targetURL, PHP_URL_SCHEME), [false, null], true)) {
137137
$targetURL = $host . $targetURL;
138138
}
139139

@@ -156,7 +156,7 @@ private function getSalesChannelContext(Request $request): SalesChannelContext
156156

157157
$languageId = $request->headers->get(PlatformRequest::HEADER_LANGUAGE_ID);
158158

159-
if (empty($languageId)) {
159+
if ($languageId === null) {
160160
throw new \RuntimeException('No language id found in request.');
161161
}
162162

src/Subscriber/isExcludedEventSubscriber.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function isBadUserAgent(IsExcludedEvent $event): void
5555

5656
$badBotsRegex = '/' . $badUserAgents . '/i';
5757

58-
if (\preg_match($badBotsRegex, $userAgent)) {
58+
if (\preg_match($badBotsRegex, $userAgent) !== false) {
5959
$event->setIsExcluded(true);
6060
}
6161
}
@@ -71,15 +71,17 @@ public function isExcluded(IsExcludedEvent $event): void
7171
$salesChannelId = $message->getSalesChannelId();
7272

7373
if (!isset($this->excludes[$salesChannelId])) {
74-
$excludes = \array_filter(\explode(PHP_EOL, $this->systemConfigService->getString('TinectRedirects.config.excludes', $salesChannelId)));
74+
$excludes = \array_filter(
75+
\explode(PHP_EOL, $this->systemConfigService->getString('TinectRedirects.config.excludes', $salesChannelId)),
76+
static fn ($exclude) => $exclude !== '');
7577
$this->excludes[$salesChannelId] = $excludes;
7678
}
7779

7880
$excludes = $this->excludes[$salesChannelId];
7981

8082
foreach ($excludes as $exclude) {
8183
try {
82-
if (\preg_match($exclude, $path)) {
84+
if (\preg_match($exclude, $path) !== false) {
8385
$event->setIsExcluded(true);
8486

8587
return;

0 commit comments

Comments
 (0)