diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 741f80c0..9d2067da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: none - run: composer install --no-interaction --prefer-dist - run: composer cs @@ -39,7 +39,7 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: none - run: composer install --no-interaction --prefer-dist - run: composer stan @@ -48,7 +48,8 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.0'] + php-version: ['8.0', '8.1'] + continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -57,10 +58,13 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: pcov ini-values: pcov.directory=module - - run: composer install --no-interaction --prefer-dist + - if: ${{ matrix.php-version == '8.1' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.1' }} + run: composer install --no-interaction --prefer-dist - run: composer test:unit:ci - uses: actions/upload-artifact@v2 if: ${{ matrix.php-version == '8.0' }} @@ -74,7 +78,8 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.0'] + php-version: ['8.0', '8.1'] + continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -83,10 +88,13 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: pcov ini-values: pcov.directory=module - - run: composer install --no-interaction --prefer-dist + - if: ${{ matrix.php-version == '8.1' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.1' }} + run: composer install --no-interaction --prefer-dist - run: composer test:db:sqlite:ci - uses: actions/upload-artifact@v2 if: ${{ matrix.php-version == '8.0' }} @@ -100,7 +108,8 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.0'] + php-version: ['8.0', '8.1'] + continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -111,16 +120,20 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: none - - run: composer install --no-interaction --prefer-dist + - if: ${{ matrix.php-version == '8.1' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.1' }} + run: composer install --no-interaction --prefer-dist - run: composer test:db:mysql db-tests-maria: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.0'] + php-version: ['8.0', '8.1'] + continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -131,16 +144,20 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: none - - run: composer install --no-interaction --prefer-dist + - if: ${{ matrix.php-version == '8.1' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.1' }} + run: composer install --no-interaction --prefer-dist - run: composer test:db:maria db-tests-postgres: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.0'] + php-version: ['8.0', '8.1'] + continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -151,16 +168,20 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: none - - run: composer install --no-interaction --prefer-dist + - if: ${{ matrix.php-version == '8.1' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.1' }} + run: composer install --no-interaction --prefer-dist - run: composer test:db:postgres db-tests-ms: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.0'] + php-version: ['8.0', '8.1'] + continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -169,13 +190,25 @@ jobs: - name: Start database server run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms - name: Use PHP + if: ${{ matrix.php-version == '8.1' }} uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7, pdo_sqlsrv-5.9.0 + extensions: swoole-4.7.1, pdo_sqlsrv-5.10.0beta1 coverage: none - - run: composer install --no-interaction --prefer-dist + - name: Use PHP + if: ${{ matrix.php-version != '8.1' }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer + extensions: swoole-4.7.1, pdo_sqlsrv-5.9.0 + coverage: none + - if: ${{ matrix.php-version == '8.1' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.1' }} + run: composer install --no-interaction --prefer-dist - name: Create test database run: docker-compose exec -T shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;" - run: composer test:db:ms @@ -184,7 +217,8 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.0'] + php-version: ['8.0', '8.1'] + continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -195,10 +229,13 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: pcov ini-values: pcov.directory=module - - run: composer install --no-interaction --prefer-dist + - if: ${{ matrix.php-version == '8.1' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.1' }} + run: composer install --no-interaction --prefer-dist - run: bin/test/run-api-tests.sh - uses: actions/upload-artifact@v2 if: ${{ matrix.php-version == '8.0' }} @@ -216,8 +253,9 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.0'] + php-version: ['8.0', '8.1'] test-group: ['unit', 'db'] + continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -226,10 +264,13 @@ jobs: with: php-version: ${{ matrix.php-version }} tools: composer - extensions: swoole-4.6.7 + extensions: swoole-4.7.1 coverage: pcov ini-values: pcov.directory=module - - run: composer install --no-interaction --prefer-dist + - if: ${{ matrix.php-version == '8.1' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.1' }} + run: composer install --no-interaction --prefer-dist - uses: actions/download-artifact@v2 with: path: build diff --git a/CHANGELOG.md b/CHANGELOG.md index c3a12e21..46f386eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ### Changed * [#1142](https://github.com/shlinkio/shlink/issues/1142) Replaced `doctrine/cache` package with `symfony/cache`. * [#1157](https://github.com/shlinkio/shlink/issues/1157) All routes now support CORS, not only rest ones. +* [#1144](https://github.com/shlinkio/shlink/issues/1144) Added experimental builds under PHP 8.1. ### Deprecated * [#1164](https://github.com/shlinkio/shlink/issues/1164) Deprecated `SHORT_DOMAIN_HOST` and `SHORT_DOMAIN_SCHEMA` env vars. Use `DEFAULT_DOMAIN` and `USE_HTTPS=true|false` instead. diff --git a/Dockerfile b/Dockerfile index d2684545..aea95a86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,9 @@ FROM php:8.0.9-alpine3.14 as base ARG SHLINK_VERSION=latest ENV SHLINK_VERSION ${SHLINK_VERSION} -ENV SWOOLE_VERSION 4.7.0 +ENV SWOOLE_VERSION 4.7.1 ENV PDO_SQLSRV_VERSION 5.9.0 -ENV MS_ODBC_SQL_VERSION 17.5.2.1 +ENV MS_ODBC_SQL_VERSION 17.5.2.2 ENV LC_ALL "C" WORKDIR /etc/shlink diff --git a/data/infra/php.Dockerfile b/data/infra/php.Dockerfile index 02e815b1..1503ddf2 100644 --- a/data/infra/php.Dockerfile +++ b/data/infra/php.Dockerfile @@ -3,7 +3,7 @@ MAINTAINER Alejandro Celaya ENV APCU_VERSION 5.1.20 ENV PDO_SQLSRV_VERSION 5.9.0 -ENV MS_ODBC_SQL_VERSION 17.5.2.1 +ENV MS_ODBC_SQL_VERSION 17.5.2.2 RUN apk update diff --git a/data/infra/swoole.Dockerfile b/data/infra/swoole.Dockerfile index 3170729b..5b4fac1c 100644 --- a/data/infra/swoole.Dockerfile +++ b/data/infra/swoole.Dockerfile @@ -2,10 +2,10 @@ FROM php:8.0.9-alpine3.14 MAINTAINER Alejandro Celaya ENV APCU_VERSION 5.1.20 -ENV PDO_SQLSRV_VERSION 5.9.0 ENV INOTIFY_VERSION 3.0.0 -ENV SWOOLE_VERSION 4.7.0 -ENV MS_ODBC_SQL_VERSION 17.5.2.1 +ENV SWOOLE_VERSION 4.7.1 +ENV PDO_SQLSRV_VERSION 5.9.0 +ENV MS_ODBC_SQL_VERSION 17.5.2.2 RUN apk update diff --git a/module/Core/src/ErrorHandler/NotFoundRedirectHandler.php b/module/Core/src/ErrorHandler/NotFoundRedirectHandler.php index 44cd2ddd..57bc4c41 100644 --- a/module/Core/src/ErrorHandler/NotFoundRedirectHandler.php +++ b/module/Core/src/ErrorHandler/NotFoundRedirectHandler.php @@ -27,16 +27,9 @@ class NotFoundRedirectHandler implements MiddlewareInterface /** @var NotFoundType $notFoundType */ $notFoundType = $request->getAttribute(NotFoundType::class); $authority = $request->getUri()->getAuthority(); - $domainSpecificRedirect = $this->resolveDomainSpecificRedirect($authority, $notFoundType); + $redirectConfig = $this->domainService->findByAuthority($authority) ?? $this->redirectOptions; + $redirectResponse = $this->redirectResolver->resolveRedirectResponse($notFoundType, $redirectConfig); - return $domainSpecificRedirect - ?? $this->redirectResolver->resolveRedirectResponse($notFoundType, $this->redirectOptions) - ?? $handler->handle($request); - } - - private function resolveDomainSpecificRedirect(string $authority, NotFoundType $notFoundType): ?ResponseInterface - { - $domain = $this->domainService->findByAuthority($authority); - return $domain === null ? null : $this->redirectResolver->resolveRedirectResponse($notFoundType, $domain); + return $redirectResponse ?? $handler->handle($request); } } diff --git a/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php b/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php index 0d257d8e..877e96b7 100644 --- a/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php +++ b/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php @@ -72,17 +72,18 @@ class NotFoundRedirectHandlerTest extends TestCase $domainService->findByAuthority(Argument::cetera()) ->willReturn(null) ->shouldBeCalledOnce(); - $resolver->resolveRedirectResponse(Argument::cetera()) - ->willReturn(null) - ->shouldBeCalledOnce(); + $resolver->resolveRedirectResponse( + Argument::type(NotFoundType::class), + Argument::type(NotFoundRedirectOptions::class), + )->willReturn(null)->shouldBeCalledOnce(); }]; yield 'non-redirecting domain' => [function (ObjectProphecy $domainService, ObjectProphecy $resolver): void { $domainService->findByAuthority(Argument::cetera()) ->willReturn(Domain::withAuthority('')) ->shouldBeCalledOnce(); - $resolver->resolveRedirectResponse(Argument::cetera()) + $resolver->resolveRedirectResponse(Argument::type(NotFoundType::class), Argument::type(Domain::class)) ->willReturn(null) - ->shouldBeCalledTimes(2); + ->shouldBeCalledOnce(); }]; }