diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94ebcc9e..1db3f3eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,6 @@ jobs: strategy: matrix: php-version: ['8.0', '8.1'] - continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -61,10 +60,7 @@ jobs: extensions: openswoole-4.8.1 coverage: pcov ini-values: pcov.directory=module - - 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 install --no-interaction --prefer-dist - run: composer test:unit:ci - uses: actions/upload-artifact@v2 if: ${{ matrix.php-version == '8.0' }} @@ -79,7 +75,6 @@ jobs: strategy: matrix: php-version: ['8.0', '8.1'] - continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -91,10 +86,7 @@ jobs: extensions: openswoole-4.8.1 coverage: pcov ini-values: pcov.directory=module - - 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 install --no-interaction --prefer-dist - run: composer test:db:sqlite:ci - uses: actions/upload-artifact@v2 if: ${{ matrix.php-version == '8.0' }} @@ -109,7 +101,6 @@ jobs: strategy: matrix: php-version: ['8.0', '8.1'] - continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -122,10 +113,7 @@ jobs: tools: composer extensions: openswoole-4.8.1 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 + - run: composer install --no-interaction --prefer-dist - run: composer test:db:mysql db-tests-maria: @@ -133,7 +121,6 @@ jobs: strategy: matrix: php-version: ['8.0', '8.1'] - continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -146,10 +133,7 @@ jobs: tools: composer extensions: openswoole-4.8.1 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 + - run: composer install --no-interaction --prefer-dist - run: composer test:db:maria db-tests-postgres: @@ -157,7 +141,6 @@ jobs: strategy: matrix: php-version: ['8.0', '8.1'] - continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -170,10 +153,7 @@ jobs: tools: composer extensions: openswoole-4.8.1 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 + - run: composer install --no-interaction --prefer-dist - run: composer test:db:postgres db-tests-ms: @@ -181,7 +161,6 @@ jobs: strategy: matrix: php-version: ['8.0', '8.1'] - continue-on-error: ${{ matrix.php-version == '8.1' }} env: LC_ALL: C steps: @@ -198,10 +177,7 @@ jobs: tools: composer extensions: openswoole-4.8.1, pdo_sqlsrv-5.10.0beta2 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 + - 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 @@ -211,7 +187,6 @@ jobs: strategy: matrix: php-version: ['8.0', '8.1'] - continue-on-error: ${{ matrix.php-version == '8.1' }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -225,10 +200,7 @@ jobs: extensions: openswoole-4.8.1 coverage: pcov ini-values: pcov.directory=module - - 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 install --no-interaction --prefer-dist - run: bin/test/run-api-tests.sh - uses: actions/upload-artifact@v2 if: ${{ matrix.php-version == '8.0' }} @@ -248,7 +220,6 @@ jobs: matrix: 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 @@ -260,10 +231,7 @@ jobs: extensions: openswoole-4.8.1 coverage: pcov ini-values: pcov.directory=module - - 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 install --no-interaction --prefer-dist - uses: actions/download-artifact@v2 with: path: build diff --git a/CHANGELOG.md b/CHANGELOG.md index b5729915..dc6cdef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ### Added * [#1204](https://github.com/shlinkio/shlink/issues/1204) Added support for `openswoole` and migrated official docker image to `openswoole`. * [#1242](https://github.com/shlinkio/shlink/issues/1242) Added support to import urls and visits from YOURLS. + + In order to do it, you need to first install this [dedicated plugin](https://slnk.to/yourls-import) in YOURLS, and then run the `short-url:import yourls` command, as with any other source. + * [#1235](https://github.com/shlinkio/shlink/issues/1235) Added support to disable rounding QR codes block sizing via config option, env var or query param. +* [#1188](https://github.com/shlinkio/shlink/issues/1188) Added support for PHP 8.1. + + The official docker image has also been updated to use PHP 8.1 by default. ### Changed * [#1218](https://github.com/shlinkio/shlink/issues/1218) Updated to symfony/mercure 0.6. diff --git a/Dockerfile b/Dockerfile index c0b803b8..d26c7848 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.0.9-alpine3.14 as base +FROM php:8.1.0-alpine3.15 as base ARG SHLINK_VERSION=latest ENV SHLINK_VERSION ${SHLINK_VERSION} diff --git a/composer.json b/composer.json index 09aaf729..2926a1af 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "geoip2/geoip2": "^2.12", "guzzlehttp/guzzle": "^7.4", "happyr/doctrine-specification": "^2.0", - "jaybizzle/crawler-detect": "^1.2", + "jaybizzle/crawler-detect": "^1.2.110", "laminas/laminas-config": "^3.7", "laminas/laminas-config-aggregator": "^1.7", "laminas/laminas-diactoros": "^2.8", @@ -41,13 +41,13 @@ "monolog/monolog": "^2.3", "nikolaposa/monolog-factory": "^3.1", "ocramius/proxy-manager": "^2.11", - "pagerfanta/core": "^2.7", + "pagerfanta/core": "^3.5", "php-middleware/request-id": "^4.1", "predis/predis": "^1.1", - "pugx/shortid-php": "^0.7", - "ramsey/uuid": "^3.9", - "rlanvin/php-ip": "3.0.0-rc2", - "shlinkio/shlink-common": "dev-main#7cc36a6 as 4.2", + "pugx/shortid-php": "^1.0", + "ramsey/uuid": "^4.2", + "rlanvin/php-ip": "dev-master#6b3a785 as 3.0", + "shlinkio/shlink-common": "dev-main#c2e3442 as 4.2", "shlinkio/shlink-config": "^1.4", "shlinkio/shlink-event-dispatcher": "dev-main#3925299 as 2.3", "shlinkio/shlink-importer": "dev-main#d099072 as 2.5", @@ -64,7 +64,7 @@ "devster/ubench": "^2.1", "dms/phpunit-arraysubset-asserts": "^0.3.0", "eaglewu/swoole-ide-helper": "dev-master", - "infection/infection": "^0.25.3", + "infection/infection": "^0.25.4", "phpspec/prophecy-phpunit": "^2.0", "phpstan/phpstan": "^1.2", "phpstan/phpstan-doctrine": "^1.0", diff --git a/data/infra/php.Dockerfile b/data/infra/php.Dockerfile index fe6c2722..86f95361 100644 --- a/data/infra/php.Dockerfile +++ b/data/infra/php.Dockerfile @@ -1,7 +1,7 @@ -FROM php:8.0.9-fpm-alpine3.14 +FROM php:8.1.0-fpm-alpine3.15 MAINTAINER Alejandro Celaya -ENV APCU_VERSION 5.1.20 +ENV APCU_VERSION 5.1.21 ENV PDO_SQLSRV_VERSION 5.10.0beta2 ENV MS_ODBC_SQL_VERSION 17.5.2.2 diff --git a/data/infra/swoole.Dockerfile b/data/infra/swoole.Dockerfile index 9cae5e73..74b83d07 100644 --- a/data/infra/swoole.Dockerfile +++ b/data/infra/swoole.Dockerfile @@ -1,7 +1,7 @@ -FROM php:8.0.9-alpine3.14 +FROM php:8.1.0-alpine3.15 MAINTAINER Alejandro Celaya -ENV APCU_VERSION 5.1.20 +ENV APCU_VERSION 5.1.21 ENV INOTIFY_VERSION 3.0.0 ENV OPENSWOOLE_VERSION 4.8.1 ENV PDO_SQLSRV_VERSION 5.10.0beta2 diff --git a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php index 53e47d3c..cbc6e3ee 100644 --- a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php +++ b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php @@ -131,7 +131,7 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand ]; if ($all) { - $data[ShortUrlsParamsInputFilter::ITEMS_PER_PAGE] = -1; + $data[ShortUrlsParamsInputFilter::ITEMS_PER_PAGE] = Paginator::ALL_ITEMS; } do { diff --git a/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php b/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php index 8150d0c8..4a974d73 100644 --- a/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php @@ -271,7 +271,7 @@ class ListShortUrlsCommandTest extends TestCase 'startDate' => null, 'endDate' => null, 'orderBy' => null, - 'itemsPerPage' => -1, + 'itemsPerPage' => Paginator::ALL_ITEMS, ]))->willReturn(new Paginator(new ArrayAdapter([]))); $this->commandTester->execute(['--all' => true]); diff --git a/module/Core/src/Model/VisitsParams.php b/module/Core/src/Model/VisitsParams.php index ed98d4d2..dd5a656d 100644 --- a/module/Core/src/Model/VisitsParams.php +++ b/module/Core/src/Model/VisitsParams.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core\Model; +use Shlinkio\Shlink\Common\Paginator\Paginator; use Shlinkio\Shlink\Common\Util\DateRange; use function Shlinkio\Shlink\Core\parseDateRangeFromQuery; @@ -11,7 +12,6 @@ use function Shlinkio\Shlink\Core\parseDateRangeFromQuery; final class VisitsParams { private const FIRST_PAGE = 1; - private const ALL_ITEMS = -1; private DateRange $dateRange; private int $page; @@ -36,10 +36,10 @@ final class VisitsParams private function determineItemsPerPage(?int $itemsPerPage): int { if ($itemsPerPage !== null && $itemsPerPage < 0) { - return self::ALL_ITEMS; + return Paginator::ALL_ITEMS; } - return $itemsPerPage ?? self::ALL_ITEMS; + return $itemsPerPage ?? Paginator::ALL_ITEMS; } public static function fromRawData(array $query): self diff --git a/module/Core/src/Repository/VisitRepository.php b/module/Core/src/Repository/VisitRepository.php index 0fe539af..5c39c21e 100644 --- a/module/Core/src/Repository/VisitRepository.php +++ b/module/Core/src/Repository/VisitRepository.php @@ -226,8 +226,6 @@ class VisitRepository extends EntitySpecificationRepository implements VisitRepo 'id' => 'visit_location_id', ]); - $query = $this->getEntityManager()->createNativeQuery($nativeQb->getSQL(), $rsm); - - return $query->getResult(); + return $this->getEntityManager()->createNativeQuery($nativeQb->getSQL(), $rsm)->getResult(); } } diff --git a/module/Core/src/Validation/ShortUrlsParamsInputFilter.php b/module/Core/src/Validation/ShortUrlsParamsInputFilter.php index 871995dd..c62845d4 100644 --- a/module/Core/src/Validation/ShortUrlsParamsInputFilter.php +++ b/module/Core/src/Validation/ShortUrlsParamsInputFilter.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core\Validation; use Laminas\InputFilter\InputFilter; +use Shlinkio\Shlink\Common\Paginator\Paginator; use Shlinkio\Shlink\Common\Validation; class ShortUrlsParamsInputFilter extends InputFilter @@ -32,7 +33,7 @@ class ShortUrlsParamsInputFilter extends InputFilter $this->add($this->createInput(self::SEARCH_TERM, false)); $this->add($this->createNumericInput(self::PAGE, false)); - $this->add($this->createNumericInput(self::ITEMS_PER_PAGE, false, -1)); + $this->add($this->createNumericInput(self::ITEMS_PER_PAGE, false, Paginator::ALL_ITEMS)); $this->add($this->createTagsInput(self::TAGS, false)); } diff --git a/module/Rest/test-api/Action/OrphanVisitsTest.php b/module/Rest/test-api/Action/OrphanVisitsTest.php index 21f4cae1..a37193da 100644 --- a/module/Rest/test-api/Action/OrphanVisitsTest.php +++ b/module/Rest/test-api/Action/OrphanVisitsTest.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace ShlinkioApiTest\Shlink\Rest\Action; use GuzzleHttp\RequestOptions; +use Shlinkio\Shlink\Common\Paginator\Paginator; use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase; class OrphanVisitsTest extends ApiTestCase @@ -51,7 +52,7 @@ class OrphanVisitsTest extends ApiTestCase $payload = $this->getJsonResponsePayload($resp); $visits = $payload['visits']['data'] ?? []; - self::assertEquals($totalItems, $payload['visits']['pagination']['totalItems'] ?? -1); + self::assertEquals($totalItems, $payload['visits']['pagination']['totalItems'] ?? Paginator::ALL_ITEMS); self::assertCount($expectedAmount, $visits); self::assertEquals($expectedVisits, $visits); } diff --git a/module/Rest/test-api/Action/ShortUrlVisitsTest.php b/module/Rest/test-api/Action/ShortUrlVisitsTest.php index 327c7c05..a9e571da 100644 --- a/module/Rest/test-api/Action/ShortUrlVisitsTest.php +++ b/module/Rest/test-api/Action/ShortUrlVisitsTest.php @@ -6,6 +6,7 @@ namespace ShlinkioApiTest\Shlink\Rest\Action; use GuzzleHttp\Psr7\Query; use Laminas\Diactoros\Uri; +use Shlinkio\Shlink\Common\Paginator\Paginator; use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase; use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait; @@ -58,7 +59,10 @@ class ShortUrlVisitsTest extends ApiTestCase $resp = $this->callApiWithKey(self::METHOD_GET, (string) $url); $payload = $this->getJsonResponsePayload($resp); - self::assertEquals($expectedAmountOfVisits, $payload['visits']['pagination']['totalItems'] ?? -1); + self::assertEquals( + $expectedAmountOfVisits, + $payload['visits']['pagination']['totalItems'] ?? Paginator::ALL_ITEMS, + ); self::assertCount($expectedAmountOfVisits, $payload['visits']['data'] ?? []); } @@ -84,7 +88,10 @@ class ShortUrlVisitsTest extends ApiTestCase $resp = $this->callApiWithKey(self::METHOD_GET, (string) $url); $payload = $this->getJsonResponsePayload($resp); - self::assertEquals($expectedAmountOfVisits, $payload['visits']['pagination']['totalItems'] ?? -1); + self::assertEquals( + $expectedAmountOfVisits, + $payload['visits']['pagination']['totalItems'] ?? Paginator::ALL_ITEMS, + ); self::assertCount($expectedAmountOfVisits, $payload['visits']['data'] ?? []); } diff --git a/phpstan.neon b/phpstan.neon index bf3afc8e..0a2433e3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,3 +9,6 @@ parameters: doctrine: repositoryClass: Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository objectManagerLoader: 'config/entity-manager.php' + ignoreErrors: + - '#should return int<0, max> but returns int#' + - '#expects -1|int<1, max>, int given#'