From 644323eb89743f76b6b6e6226510133ad54a2d3e Mon Sep 17 00:00:00 2001 From: Peter van der Wal Date: Mon, 27 May 2024 14:44:45 +0200 Subject: [PATCH 1/5] Correct PHP versions in README.md Readme still contained PHP versions that aren't supported anymore --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f92fcb..b3d8505 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Webgriffe ESB is designed to use a single binary which is used as the main entry Requirements ------------ -* PHP 7.2, 7.3 or 7.4 +* PHP 7.4 or 8.0 * Beanstalk * Elasticsearch 7.* From 23680a5e547117f6e523d0360bba60f25d33c5e4 Mon Sep 17 00:00:00 2001 From: Peter van der Wal Date: Mon, 27 May 2024 15:38:42 +0200 Subject: [PATCH 2/5] Add PHP 8.3 support --- .github/workflows/ci.yaml | 2 +- Dockerfile | 2 +- README.md | 2 +- composer.json | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 945df14..36becbc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - php: [7.4, 8.0] + php: [7.4, 8.0, 8.1, 8.2, 8.3] env: ESB_CONSOLE_PORT: 8080 diff --git a/Dockerfile b/Dockerfile index c3ab0fa..1183000 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG PHP_VERSION=8.0 +ARG PHP_VERSION=8.3 FROM php:${PHP_VERSION}-cli-alpine diff --git a/README.md b/README.md index b3d8505..9425545 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Webgriffe ESB is designed to use a single binary which is used as the main entry Requirements ------------ -* PHP 7.4 or 8.0 +* PHP 7.4, 8.0, 8.1, 8.2, 8.3 * Beanstalk * Elasticsearch 7.* diff --git a/composer.json b/composer.json index 7e7334e..8d6307d 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": "~7.4.0|~8.0.0", + "php": "~7.4.0|~8.0.0|~8.1.0|~8.2.0|~8.3.0", "ext-pcntl": "*", "ext-json": "*", "symfony/dependency-injection": "^4.3", @@ -33,7 +33,7 @@ "symfony/property-info": "^4.3", "doctrine/annotations": "^1.8", "ramsey/uuid": "^3.8", - "webgriffe/amp-elasticsearch": "^2.0", + "webgriffe/amp-elasticsearch": "^2.1", "pagerfanta/pagerfanta": "^2.4", "symfony/deprecation-contracts": "^2.1", "amphp/http-server-form-parser": "^1.1" From d498e1e59f929e101108454469789df4f0e4a37f Mon Sep 17 00:00:00 2001 From: Peter van der Wal Date: Mon, 27 May 2024 15:42:32 +0200 Subject: [PATCH 3/5] Replace deprecated utf8_encode with mb_convert_encoding Error: Function utf8_encode() is deprecated in /srv/esb/vendor/monolog/monolog/src/Monolog/Utils.php on line 179 Resolved with: Implementing Monolog\Utils::detectAndCleanUtf8() from Monolog version 2.8 --- .github/workflows/ci.yaml | 2 +- composer-require-checker.json | 8 +++++++- composer.json | 3 +++ src/NonUtf8Cleaner.php | 29 ++++++++++++++++++++++++----- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 36becbc..b3ab3ef 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -68,7 +68,7 @@ jobs: run: composer install --no-interaction - name: Composer Require Checker - run: composer-require-checker + run: composer-require-checker --config-file=composer-require-checker.json - name: Run Easy Coding Standard run: vendor/bin/ecs check diff --git a/composer-require-checker.json b/composer-require-checker.json index 6d5bb51..7dfd157 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -1,3 +1,9 @@ { - "scan-files" : ["bin/esb"] + "scan-files" : ["bin/esb"], + "symbol-whitelist": [ + "null", "true", "false", "static", "self", "parent", + "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "mixed", "never", + + "mb_convert_encoding" + ] } diff --git a/composer.json b/composer.json index 8d6307d..473f144 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,9 @@ "symfony/deprecation-contracts": "^2.1", "amphp/http-server-form-parser": "^1.1" }, + "suggest": { + "ext-mbstring": "*" + }, "autoload": { "psr-4": { "Webgriffe\\Esb\\": ["src/"] diff --git a/src/NonUtf8Cleaner.php b/src/NonUtf8Cleaner.php index 88a9b1b..b1e296d 100644 --- a/src/NonUtf8Cleaner.php +++ b/src/NonUtf8Cleaner.php @@ -4,8 +4,6 @@ namespace Webgriffe\Esb; -use Monolog\Utils; - /** * @internal */ @@ -17,13 +15,34 @@ class NonUtf8Cleaner */ public static function clean(array $data): array { - array_walk_recursive($data, [Utils::class, 'detectAndCleanUtf8']); + array_walk_recursive($data, [__CLASS__, 'cleanString']); return $data; } public static function cleanString(string $data): string { - Utils::detectAndCleanUtf8($data); - return $data; + // Implementation borrowed from Monolog\Utils::detectAndCleanUtf8() which is no longer a public method as of version 2 + + if (preg_match('//u', $data)) { + return $data; + } + + $data = preg_replace_callback( + '/[\x80-\xFF]+/', + function ($m) { + return function_exists('mb_convert_encoding') ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1') : utf8_encode($m[0]); + }, + $data + ); + + if (!is_string($data)) { + throw new \RuntimeException('Failed to preg_replace_callback: ' . preg_last_error()); + } + + return str_replace( + ['¤', '¦', '¨', '´', '¸', '¼', '½', '¾'], + ['€', 'Š', 'š', 'Ž', 'ž', 'Œ', 'œ', 'Ÿ'], + $data + ); } } From 3104116a7efc1c87ea56491a4e7a10ca7ea5487a Mon Sep 17 00:00:00 2001 From: Peter van der Wal Date: Mon, 27 May 2024 16:45:21 +0200 Subject: [PATCH 4/5] Install Roave BC Check in separate directory To avoid dependency conflicts with project dependencies, require BC Check tool in a separate directory --- .github/workflows/ci.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b3ab3ef..7e5cc62 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -84,7 +84,10 @@ jobs: run: sudo bash ./upload-textfiles "/var/log/elasticsearch/*.log" - name: Install roave/backward-compatibility-check. - run: composer require -W --dev roave/backward-compatibility-check --no-plugins + run: | + # Install BC check tool in separate directory to avoid dependency conflicts + mkdir -p test-tools/bc-check + composer require --working-dir="test-tools/bc-check" roave/backward-compatibility-check --no-plugins - name: Run roave/backward-compatibility-check. - run: vendor/bin/roave-backward-compatibility-check --format=github-actions + run: test-tools/bc-check/vendor/bin/roave-backward-compatibility-check --format=github-actions From 483446611b89b593b86faad2daae0a4eb943e0c9 Mon Sep 17 00:00:00 2001 From: Peter van der Wal Date: Mon, 27 May 2024 15:46:38 +0200 Subject: [PATCH 5/5] [TO BE DROPPED BEFORE MERGING]: install amp-elasticsearch from source --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 473f144..4a10cf7 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "symfony/property-info": "^4.3", "doctrine/annotations": "^1.8", "ramsey/uuid": "^3.8", - "webgriffe/amp-elasticsearch": "^2.1", + "webgriffe/amp-elasticsearch": "dev-php-8.3-support#6b26a581fc99c6aba5b06fc2eabfe2dec98578c9 as 2.1", "pagerfanta/pagerfanta": "^2.4", "symfony/deprecation-contracts": "^2.1", "amphp/http-server-form-parser": "^1.1" @@ -68,5 +68,11 @@ "phpstan": "vendor/bin/phpstan analyse --no-progress -l max -c phpstan.neon src/", "phpunit": "vendor/bin/phpunit", "tests": ["@ecs", "@phpstan", "@phpunit"] + }, + "repositories": { + "amp-elasticsearch-from-src": { + "type": "vcs", + "url": "git@github.com:youwe-petervanderwal/amp-elasticsearch.git" + } } }