From 9e183ddad06caaaf70140404077ca75e812d1bc5 Mon Sep 17 00:00:00 2001 From: tinect Date: Sat, 28 Dec 2024 03:12:13 +0100 Subject: [PATCH 1/9] chore: use matrix generator --- .github/workflows/code-style.yml | 30 ++++++++++++++++++++++++++++-- phpstan.neon.dist | 9 +++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 21821327..5dcfe331 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -10,8 +10,34 @@ jobs: cs: if: github.event_name != 'schedule' uses: shopware/github-actions/.github/workflows/cs-fixer.yml@main + get-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.matrix.outputs.matrix }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Get Shopware Version + id: shopware-constraint + run: echo "shopware_constraint=$(cat composer.json | jq -r '.require."shopware/core"')" >> $GITHUB_OUTPUT + + - name: Get Shopware Matrix + uses: tinect/github-shopware-matrix-generator@main + id: matrix + with: + versionConstraint: ${{ steps.shopware-constraint.outputs.shopware_constraint }} + allowEol: false + justMinMaxShopware: false + allowShopwareNext: true + allowShopwareRC: false phpstan: + name: PHPStan + needs: get-matrix + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.get-matrix.outputs.matrix) }} uses: shopware/github-actions/.github/workflows/phpstan.yml@main with: - extensionName: FroshTools - shopwareVersion: v6.6.0.0-rc1 + extensionName: FroshTools + shopwareVersion: ${{ matrix.shopware }} diff --git a/phpstan.neon.dist b/phpstan.neon.dist index aafcb7b4..81c2d442 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,7 +2,8 @@ parameters: level: 8 paths: - src - type_coverage: - return_type: 100 - param_type: 98 - property_type: 100 + + ignoreErrors: + - + message: "#^Out of .* possible param types, only .* %% actually have it\\. Add more param types to get over .* %%$#" + reportUnmatched: false From 08c9ebc7e3a4451321717474bbf9857a0751c4ca Mon Sep 17 00:00:00 2001 From: tinect Date: Sat, 28 Dec 2024 03:23:56 +0100 Subject: [PATCH 2/9] feat: reuse versionMetaPos in MysqlChecker --- src/Components/Health/Checker/HealthChecker/MysqlChecker.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Components/Health/Checker/HealthChecker/MysqlChecker.php b/src/Components/Health/Checker/HealthChecker/MysqlChecker.php index 4ee105da..485d13f1 100644 --- a/src/Components/Health/Checker/HealthChecker/MysqlChecker.php +++ b/src/Components/Health/Checker/HealthChecker/MysqlChecker.php @@ -100,8 +100,9 @@ private function checkMysqlVersion(HealthCollection $collection, string $version private function extract(string $versionString): array { if (mb_stripos($versionString, 'mariadb') === false) { - if (mb_strpos($versionString, '-')) { - $versionString = mb_substr($versionString, 0, mb_strpos($versionString, '-')); + $versionMetaPos = mb_strpos($versionString, '-'); + if ($versionMetaPos) { + $versionString = mb_substr($versionString, 0, $versionMetaPos); } return ['mysql' => $versionString]; From 930b4259fdf6e516f73fe510085049bb68513b81 Mon Sep 17 00:00:00 2001 From: tinect Date: Sat, 28 Dec 2024 03:24:44 +0100 Subject: [PATCH 3/9] fix: throw exception if bufferSize is below 1 --- src/Components/LineReader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/LineReader.php b/src/Components/LineReader.php index b0671137..de2972c7 100644 --- a/src/Components/LineReader.php +++ b/src/Components/LineReader.php @@ -100,7 +100,7 @@ private static function readBackwards($fh, int $pos): \Generator $pos -= $bufferSize; } fseek($fh, $pos); - if ($bufferSize < 0) { + if ($bufferSize < 1) { throw new \RuntimeException('Buffer size cannot be negative'); } $chunk = fread($fh, $bufferSize); From e0c9a776db91ec2cf877a473ef4a124c3f764835 Mon Sep 17 00:00:00 2001 From: tinect Date: Sat, 28 Dec 2024 03:47:30 +0100 Subject: [PATCH 4/9] chore: ignore PHP version for matrix --- .github/workflows/code-style.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 5dcfe331..ca992657 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -31,6 +31,7 @@ jobs: justMinMaxShopware: false allowShopwareNext: true allowShopwareRC: false + includePhpVersion: false phpstan: name: PHPStan needs: get-matrix From 0b4f90d74f0284c475169a077b46bc5c0b4cf995 Mon Sep 17 00:00:00 2001 From: tinect Date: Tue, 28 Jan 2025 13:03:02 +0100 Subject: [PATCH 5/9] chore: just test min and max shopware version --- .github/workflows/code-style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index ca992657..3fe4fc17 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -28,7 +28,7 @@ jobs: with: versionConstraint: ${{ steps.shopware-constraint.outputs.shopware_constraint }} allowEol: false - justMinMaxShopware: false + justMinMaxShopware: true allowShopwareNext: true allowShopwareRC: false includePhpVersion: false From b9698991937f4d886c2fd65d1e8de2253fcc0cd8 Mon Sep 17 00:00:00 2001 From: tinect Date: Wed, 29 Jan 2025 15:45:48 +0100 Subject: [PATCH 6/9] feat: migrate code of DatabaseConnectionInformation into own checker --- .../HealthChecker/SystemInfoChecker.php | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php b/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php index c7b6ff2b..3edd7199 100644 --- a/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php +++ b/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php @@ -7,7 +7,7 @@ use Frosh\Tools\Components\Health\Checker\CheckerInterface; use Frosh\Tools\Components\Health\HealthCollection; use Frosh\Tools\Components\Health\SettingsResult; -use Shopware\Core\Maintenance\System\Struct\DatabaseConnectionInformation; +use Shopware\Core\DevOps\Environment\EnvironmentHelper; use Symfony\Component\DependencyInjection\Attribute\Autowire; class SystemInfoChecker implements HealthCheckerInterface, CheckerInterface @@ -36,20 +36,44 @@ private function checkPath(HealthCollection $collection): void private function getDatabaseInfo(HealthCollection $collection): void { - $databaseConnectionInfo = (new DatabaseConnectionInformation())->fromEnv(); + $result = new SettingsResult(); + $result->assign([ + 'id' => 'database-info', + 'snippet' => 'Database', + 'current' => 'unknown', + ]); - $collection->add( - SettingsResult::ok( - 'database-info', - 'Database', - \sprintf( - '%s@%s:%d/%s', - $databaseConnectionInfo->getUsername(), - $databaseConnectionInfo->getHostname(), - $databaseConnectionInfo->getPort(), - $databaseConnectionInfo->getDatabaseName(), - ), - ), - ); + try { + $dsn = trim((string) EnvironmentHelper::getVariable('DATABASE_URL', getenv('DATABASE_URL'))); + if ($dsn === '') { + return; + } + + $params = parse_url($dsn); + if ($params === false) { + return; + } + + foreach ($params as $param => $value) { + if (!\is_string($value)) { + continue; + } + + $params[$param] = rawurldecode($value); + } + + $path = (string) ($params['path'] ?? '/'); + $dbName = trim(substr($path, 1)); + + $result->current =\sprintf( + '%s@%s:%d/%s', + $params['user'] ?? null, + $params['host'] ?? null, + (int) ($params['port'] ?? '3306'), + $dbName, + ); + } finally { + $collection->add($result); + } } } From fdfcf984627f52f6851fdc6c7acbd3169644f42b Mon Sep 17 00:00:00 2001 From: tinect Date: Wed, 29 Jan 2025 15:46:15 +0100 Subject: [PATCH 7/9] chore: ignore deprecated class CacheDecorator --- phpstan.neon.dist | 9 +++++++++ src/Components/CacheAdapter.php | 1 + 2 files changed, 10 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 81c2d442..639f77e5 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,3 +7,12 @@ parameters: - message: "#^Out of .* possible param types, only .* %% actually have it\\. Add more param types to get over .* %%$#" reportUnmatched: false + + - + message: """ + #^Fetching class constant class of deprecated class Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Cache\\\\CacheDecorator\\: + tag\\:v6\\.7\\.0 \\- reason\\:decoration\\-will\\-be\\-removed \\- Will be removed$# + """ + reportUnmatched: false + count: 1 + path: src/Components/CacheAdapter.php diff --git a/src/Components/CacheAdapter.php b/src/Components/CacheAdapter.php index 202ab6d2..be17d826 100644 --- a/src/Components/CacheAdapter.php +++ b/src/Components/CacheAdapter.php @@ -112,6 +112,7 @@ public function getType(): string private function getCacheAdapter(AdapterInterface $adapter): AdapterInterface { + // will be removed in Shopware 6.7 if ($adapter instanceof CacheDecorator) { // Do not declare function as static $func = \Closure::bind(fn() => $adapter->decorated, $adapter, $adapter::class); From f50d9b8ba609a894a04e1c2c21d60d1216273302 Mon Sep 17 00:00:00 2001 From: frosh-automation <188718289+frosh-automation[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:10:36 +0000 Subject: [PATCH 8/9] fix: code-style --- .../Health/Checker/HealthChecker/SystemInfoChecker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php b/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php index 3edd7199..b5b4b089 100644 --- a/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php +++ b/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php @@ -65,7 +65,7 @@ private function getDatabaseInfo(HealthCollection $collection): void $path = (string) ($params['path'] ?? '/'); $dbName = trim(substr($path, 1)); - $result->current =\sprintf( + $result->current = \sprintf( '%s@%s:%d/%s', $params['user'] ?? null, $params['host'] ?? null, From 7ed13f8be60f8bf12b6bef145ee1f3eb1af595b4 Mon Sep 17 00:00:00 2001 From: tinect Date: Sat, 8 Feb 2025 12:58:47 +0100 Subject: [PATCH 9/9] chore: allow RC versions --- .github/workflows/code-style.yml | 2 +- composer.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 3fe4fc17..4ebe3334 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -30,7 +30,7 @@ jobs: allowEol: false justMinMaxShopware: true allowShopwareNext: true - allowShopwareRC: false + allowShopwareRC: true includePhpVersion: false phpstan: name: PHPStan diff --git a/composer.json b/composer.json index c9a3dbd7..9f60cf62 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,7 @@ "require": { "shopware/core": "~6.6.0" }, + "minimum-stability": "RC", "config": { "allow-plugins": { "symfony/runtime": true