Skip to content

Commit

Permalink
Merge branch 'next-26756/undundle-filesystem-adapter-dependencies' in…
Browse files Browse the repository at this point in the history
…to 'trunk'

NEXT-26756 - Undundle filesystem adapter dependencies

See merge request shopware/6/product/platform!11768
  • Loading branch information
jozsefdamokos committed Nov 22, 2023
2 parents 38a0bbe + eac839a commit 556cb84
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 280 deletions.
19 changes: 19 additions & 0 deletions changelog/_unreleased/2023-11-08-undundle-storage-adapters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Undundle storage adapters
issue: NEXT-26756
author: Jozsef Damokos
author_email: [email protected]
author_github: jozsefdamokos
---
# Core
* Removed dependency on storage adapter packages `league/flysystem-async-aws-s3` and `league/flysystem-google-cloud-storage`. These are now optional and can be installed separately.
___
# Upgrade Information
## Removed dependencies to storage adapters
Removed composer packages `league/flysystem-async-aws-s3` and `league/flysystem-google-cloud-storage`. If your installation uses the AWS S3 or Google Cloud storage adapters, you need to install the corresponding packages separately.

Run the following commands to install the packages:
```bash
composer require league/flysystem-async-aws-s3
composer require league/flysystem-google-cloud-storage
```
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"ext-zip": "*",
"ext-zlib": "*",
"composer-runtime-api": "^2.0",
"async-aws/simple-s3": "^1.1",
"cocur/slugify": "^4.3.0",
"composer/composer": "^2.4.4",
"composer/semver": "^3.2",
Expand All @@ -76,8 +75,6 @@
"guzzlehttp/psr7": "^2.4",
"lcobucci/jwt": "^4.2",
"league/flysystem": "^3.10.3",
"league/flysystem-async-aws-s3": "^3.10.3",
"league/flysystem-google-cloud-storage": "^3.10.3",
"league/flysystem-memory": "^3.10.3",
"league/mime-type-detection": "^1.13.0",
"league/oauth2-server": "^8.5",
Expand Down Expand Up @@ -114,6 +111,7 @@
"symfony/filesystem": "~6.3.0",
"symfony/finder": "~6.3.0",
"symfony/framework-bundle": "~6.3.0",
"symfony/http-client": "~6.3.0",
"symfony/http-foundation": "~6.3.0",
"symfony/http-kernel": "~6.3.0",
"symfony/lock": "~6.3.0",
Expand Down Expand Up @@ -159,6 +157,8 @@
"jdorn/sql-formatter": "~1.2.17",
"johnkary/phpunit-speedtrap": "~4.0.0",
"league/construct-finder": "^1.1",
"league/flysystem-async-aws-s3": "^3.10.3",
"league/flysystem-google-cloud-storage": "^3.10.3",
"nikic/php-parser": "^4.15.0",
"opis/json-schema": "^2.3.0",
"phpbench/phpbench": "^1.2",
Expand All @@ -184,7 +184,9 @@
"tomasvotruba/type-coverage": "^0.2.1"
},
"suggest": {
"shopware/dev-tools": "For development tools, profiler, faker, etc"
"shopware/dev-tools": "For development tools, profiler, faker, etc",
"league/flysystem-async-aws-s3": "Required to use the Flysystem S3 driver (^3.10.3)",
"league/flysystem-google-cloud-storage": "Required to use the Flysystem Google cloud driver (^3.10.3)"
},
"repositories": [
{
Expand Down
55 changes: 0 additions & 55 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4160,56 +4160,6 @@ parameters:
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/AdapterFactoryInterface.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\GoogleStorageFactory\\:\\:create\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/GoogleStorageFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\GoogleStorageFactory\\:\\:resolveStorageConfig\\(\\) has parameter \\$definition with no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/GoogleStorageFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\GoogleStorageFactory\\:\\:resolveStorageConfig\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/GoogleStorageFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\LocalFactory\\:\\:create\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/LocalFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\LocalFactory\\:\\:resolveDirectoryPermissions\\(\\) has parameter \\$permissions with no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/LocalFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\LocalFactory\\:\\:resolveDirectoryPermissions\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/LocalFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\LocalFactory\\:\\:resolveFilePermissions\\(\\) has parameter \\$permissions with no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/LocalFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\LocalFactory\\:\\:resolveFilePermissions\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/LocalFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\LocalFactory\\:\\:resolveOptions\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/LocalFactory.php

-
message: "#^Method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Filesystem\\\\Adapter\\\\LocalFactory\\:\\:resolveOptions\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Core/Framework/Adapter/Filesystem/Adapter/LocalFactory.php

-
message: "#^Parameter \\#1 \\$tags of method Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Cache\\\\CacheInvalidator\\:\\:invalidate\\(\\) expects list\\<string\\>, array\\<non\\-falsy\\-string\\> given\\.$#"
count: 1
Expand Down Expand Up @@ -6250,11 +6200,6 @@ parameters:
count: 1
path: src/Core/Framework/Struct/Serializer/StructDecoder.php

-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: src/Core/Framework/Test/Adapter/Filesystem/Adapter/GoogleStorageFactoryTest.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Shopware\\\\\\\\Core\\\\\\\\Framework\\\\\\\\Adapter\\\\\\\\Twig\\\\\\\\AppTemplateIterator' and Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Twig\\\\AppTemplateIterator will always evaluate to true\\.$#"
count: 1
Expand Down
13 changes: 13 additions & 0 deletions src/Core/Framework/Adapter/AdapterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AdapterException extends HttpException
public const UNEXPECTED_TWIG_EXPRESSION = 'FRAMEWORK__UNEXPECTED_TWIG_EXPRESSION';
public const MISSING_EXTENDING_TWIG_TEMPLATE = 'FRAMEWORK__MISSING_EXTENDING_TWIG_TEMPLATE';
public const TEMPLATE_SCOPE_DEFINITION_ERROR = 'FRAMEWORK__TEMPLATE_SCOPE_DEFINITION_ERROR';
public const MISSING_DEPENDENCY_ERROR_CODE = 'FRAMEWORK__FILESYSTEM_ADAPTER_DEPENDENCY_MISSING';

public static function unexpectedTwigExpression(AbstractExpression $expression): self
{
Expand Down Expand Up @@ -49,4 +50,16 @@ public static function invalidTemplateScope(mixed $scope): self
],
);
}

public static function missingDependency(string $dependency): self
{
return new self(
Response::HTTP_FAILED_DEPENDENCY,
self::MISSING_DEPENDENCY_ERROR_CODE,
'Missing dependency "{{ dependency }}". Check the suggested composer dependencies for version and install the package.',
[
'dependency' => $dependency,
],
);
}
}
21 changes: 13 additions & 8 deletions src/Core/Framework/Adapter/Filesystem/Adapter/AwsS3v3Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Shopware\Core\Framework\Adapter\Filesystem\Adapter;

use AsyncAws\SimpleS3\SimpleS3Client;
use AsyncAws\S3\S3Client;
use League\Flysystem\AsyncAwsS3\AsyncAwsS3Adapter;
use League\Flysystem\AsyncAwsS3\PortableVisibilityConverter;
use League\Flysystem\FilesystemAdapter;
use Shopware\Core\Framework\Adapter\AdapterException;
use Shopware\Core\Framework\Log\Package;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand All @@ -20,6 +21,8 @@ class AwsS3v3Factory implements AdapterFactoryInterface
*/
public function create(array $config): FilesystemAdapter
{
$this->validateDependencies();

$options = $this->resolveS3Options($config);

$s3Opts = [
Expand All @@ -39,14 +42,9 @@ public function create(array $config): FilesystemAdapter
$s3Opts['accessKeySecret'] = $options['credentials']['secret'];
}

$client = new SimpleS3Client($s3Opts);
$client = new S3Client($s3Opts);

return new DecoratedAsyncS3Adapter(
new AsyncAwsS3Adapter($client, $options['bucket'], $options['root'], new PortableVisibilityConverter()),
$options['bucket'],
$client,
$options['root']
);
return new AsyncAwsS3Adapter($client, $options['bucket'], $options['root'], new PortableVisibilityConverter());
}

public function getType(): string
Expand Down Expand Up @@ -105,4 +103,11 @@ private function resolveCredentialsOptions(array $credentials): array

return $resolved;
}

private function validateDependencies(): void
{
if (!class_exists(AsyncAwsS3Adapter::class)) {
throw AdapterException::missingDependency('league/flysystem-async-aws-s3');
}
}
}

This file was deleted.

Loading

0 comments on commit 556cb84

Please sign in to comment.