diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81712ef..ae5e8a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,21 +15,42 @@ jobs: matrix: php: [ '8.1', '8.2'] TYPO3: ['11', '12' ] + include: + - TYPO3: '13' + php: '8.3' steps: - name: Checkout - uses: actions/checkout@v2 - - - name: Install testing system - run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s composerInstall + uses: actions/checkout@v4 + - name: Set up PHP Version + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 - name: Composer validate - run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s composerValidate - - - name: Lint PHP - run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s lint - - - name: CGL - run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s cgl -n + run: composer validate + - name: Install composer dependencies TYPO3 13 + if: matrix.TYPO3 == '13' + run: | + composer install --no-progress --no-interaction + + - name: Install composer dependencies TYPO3 12 + if: matrix.TYPO3 == '12' + run: | + composer require typo3/cms-core:^12.4 --no-progress --no-interaction --dev -W + - name: Install composer dependencies TYPO3 11 + if: matrix.TYPO3 == '11' + run: | + composer require typo3/cms-core:^11.5 --no-progress --no-interaction --dev -W + - name: Phpstan 11 + if: matrix.TYPO3 == '11' + run: .Build/bin/phpstan analyze -c Build/phpstan11.neon + - name: Phpstan 12 + if: matrix.TYPO3 == '12' + run: .Build/bin/phpstan analyze -c Build/phpstan12.neon + - name: Phpstan 13 + if: matrix.TYPO3 == '13' + run: .Build/bin/phpstan analyze -c Build/phpstan13.neon + - name: Phpcsfix + run: .Build/bin/php-cs-fixer fix --config=Build/php-cs-fixer.php --dry-run --stop-on-violation --using-cache=no - - name: phpstan - run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s phpstan diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8fedc8f..37ccac3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,13 +8,13 @@ jobs: publish: name: Publish new version to TER if: startsWith(github.ref, 'refs/tags/') - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Check tag run: | @@ -37,7 +37,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.3 extensions: intl, mbstring, json, zip, curl - name: Install tailor diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh deleted file mode 100755 index ec077dc..0000000 --- a/Build/Scripts/runTests.sh +++ /dev/null @@ -1,302 +0,0 @@ -#!/usr/bin/env bash - -# -# TYPO3 core test runner based on docker and docker-compose. -# - -# Function to write a .env file in Build/testing-docker/local -# This is read by docker-compose and vars defined here are -# used in Build/testing-docker/local/docker-compose.yml -setUpDockerComposeDotEnv() { - # Delete possibly existing local .env file if exists - [ -e .env ] && rm .env - # Set up a new .env file for docker-compose - echo "COMPOSE_PROJECT_NAME=local" >> .env - # To prevent access rights of files created by the testing, the docker image later - # runs with the same user that is currently executing the script. docker-compose can't - # use $UID directly itself since it is a shell variable and not an env variable, so - # we have to set it explicitly here. - echo "HOST_UID=`id -u`" >> .env - # Your local home directory for composer and npm caching - echo "HOST_HOME=${HOME}" >> .env - # Your local user - echo "ROOT_DIR"=${ROOT_DIR} >> .env - echo "HOST_USER=${USER}" >> .env - echo "TEST_FILE=${TEST_FILE}" >> .env - echo "PHP_XDEBUG_ON=${PHP_XDEBUG_ON}" >> .env - echo "PHP_XDEBUG_PORT=${PHP_XDEBUG_PORT}" >> .env - echo "DOCKER_PHP_IMAGE=${DOCKER_PHP_IMAGE}" >> .env - echo "TYPO3=${TYPO3}" >> .env - echo "PHP_VERSION=${PHP_VERSION}" >> .env - echo "EXTRA_TEST_OPTIONS=${EXTRA_TEST_OPTIONS}" >> .env - echo "SCRIPT_VERBOSE=${SCRIPT_VERBOSE}" >> .env - echo "CGLCHECK_DRY_RUN=${CGLCHECK_DRY_RUN}" >> .env -} - -# Load help text into $HELP -read -r -d '' HELP < - Specifies which test suite to run - - acceptance: backend acceptance tests - - composerInstall: "composer install", handy if host has no PHP, uses composer cache of users home - - composerValidate: "composer validate" - - functional: functional tests - - lint: PHP linting - - unit (default): PHP unit tests - - -t <10|11> - Only with -s composerInstall|phpstan - TYPO3 core major version the extension is embedded in for testing. - - -d - Only with -s functional - Specifies on which DBMS tests are performed - - mariadb (default): use mariadb - - mssql: use mssql microsoft sql server - - postgres: use postgres - - sqlite: use sqlite - - -p <7.2|7.3|7.4|8.0|8.1> - Specifies the PHP minor version to be used - - 7.4 (default): use PHP 7.4 - - -e "" - Only with -s acceptance|functional|unit - Additional options to send to phpunit (unit & functional tests) or codeception (acceptance - tests). For phpunit, options starting with "--" must be added after options starting with "-". - Example -e "-v --filter canRetrieveValueWithGP" to enable verbose output AND filter tests - named "canRetrieveValueWithGP" - - -x - Only with -s functional|unit|acceptance - Send information to host instance for test or system under test break points. This is especially - useful if a local PhpStorm instance is listening on default xdebug port 9000. A different port - can be selected with -y - - -y - Send xdebug information to a different port than default 9000 if an IDE like PhpStorm - is not listening on default port. - - -n - Only with -s cgl - Activate dry-run in CGL check that does not actively change files and only prints broken ones. - - -u - Update existing typo3gmbh/phpXY:latest docker images. Maintenance call to docker pull latest - versions of the main php images. The images are updated once in a while and only the youngest - ones are supported by core testing. Use this if weird test errors occur. Also removes obsolete - image versions of typo3gmbh/phpXY. - - -v - Enable verbose script output. Shows variables and docker commands. - - -h - Show this help. - -Examples: - # Run unit tests using PHP 7.4 - ./Build/Scripts/runTests.sh - - # Run unit tests using PHP 7.3 - ./Build/Scripts/runTests.sh -p 7.3 -EOF - -# Test if docker-compose exists, else exit out with error -if ! type "docker-compose" > /dev/null; then - echo "This script relies on docker and docker-compose. Please install" >&2 - exit 1 -fi - -# Go to the directory this script is located, so everything else is relative -# to this dir, no matter from where this script is called. -THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -cd "$THIS_SCRIPT_DIR" || exit 1 - -# Go to directory that contains the local docker-compose.yml file -cd ../testing-docker || exit 1 - -# Option defaults -ROOT_DIR=`readlink -f ${PWD}/../../` -TEST_SUITE="unit" -DBMS="mariadb" -PHP_VERSION="7.4" -PHP_XDEBUG_ON=0 -PHP_XDEBUG_PORT=9000 -EXTRA_TEST_OPTIONS="" -SCRIPT_VERBOSE=0 -TYPO3="10" - -# Option parsing -# Reset in case getopts has been used previously in the shell -OPTIND=1 -# Array for invalid options -INVALID_OPTIONS=(); -# Simple option parsing based on getopts (! not getopt) -while getopts ":s:d:p:e:t:xy:nhuvf" OPT; do - case ${OPT} in - s) - TEST_SUITE=${OPTARG} - ;; - d) - DBMS=${OPTARG} - ;; - p) - PHP_VERSION=${OPTARG} - ;; - t) - TYPO3=${OPTARG} - ;; - e) - EXTRA_TEST_OPTIONS=${OPTARG} - ;; - x) - PHP_XDEBUG_ON=1 - ;; - y) - PHP_XDEBUG_PORT=${OPTARG} - ;; - h) - echo "${HELP}" - exit 0 - ;; - n) - CGLCHECK_DRY_RUN="-n" - ;; - u) - TEST_SUITE=update - ;; - v) - SCRIPT_VERBOSE=1 - ;; - \?) - INVALID_OPTIONS+=(${OPTARG}) - ;; - :) - INVALID_OPTIONS+=(${OPTARG}) - ;; - esac -done - -# Exit on invalid options -if [ ${#INVALID_OPTIONS[@]} -ne 0 ]; then - echo "Invalid option(s):" >&2 - for I in "${INVALID_OPTIONS[@]}"; do - echo "-"${I} >&2 - done - echo >&2 - echo "${HELP}" >&2 - exit 1 -fi - -# Move "7.2" to "php72", the latter is the docker container name -DOCKER_PHP_IMAGE=`echo "php${PHP_VERSION}" | sed -e 's/\.//'` - -# Set $1 to first mass argument, this is the optional test file or test directory to execute -shift $((OPTIND - 1)) -if [ -n "${1}" ]; then - TEST_FILE="Web/typo3conf/ext/proxycachemanager/${1}" -fi - -if [ ${SCRIPT_VERBOSE} -eq 1 ]; then - set -x -fi - -# Suite execution -case ${TEST_SUITE} in - acceptance) - setUpDockerComposeDotEnv - docker-compose run acceptance_backend_mariadb10 - SUITE_EXIT_CODE=$? - docker-compose down - ;; - cgl) - # Active dry-run for cgl needs not "-n" but specific options - if [ -n "${CGLCHECK_DRY_RUN}" ]; then - CGLCHECK_DRY_RUN="--dry-run --diff" - fi - setUpDockerComposeDotEnv - docker-compose run cgl - SUITE_EXIT_CODE=$? - docker-compose down - ;; - composerInstall) - setUpDockerComposeDotEnv - docker-compose run composer_install - SUITE_EXIT_CODE=$? - docker-compose down - ;; - composerValidate) - setUpDockerComposeDotEnv - docker-compose run composer_validate - SUITE_EXIT_CODE=$? - docker-compose down - ;; - functional) - setUpDockerComposeDotEnv - case ${DBMS} in - mariadb) - docker-compose run functional_mariadb10 - SUITE_EXIT_CODE=$? - ;; - mssql) - docker-compose run functional_mssql2019latest - SUITE_EXIT_CODE=$? - ;; - postgres) - docker-compose run functional_postgres10 - SUITE_EXIT_CODE=$? - ;; - sqlite) - docker-compose run functional_sqlite - SUITE_EXIT_CODE=$? - ;; - *) - echo "Invalid -d option argument ${DBMS}" >&2 - echo >&2 - echo "${HELP}" >&2 - exit 1 - esac - docker-compose down - ;; - lint) - setUpDockerComposeDotEnv - docker-compose run lint - SUITE_EXIT_CODE=$? - docker-compose down - ;; - phpstan) - setUpDockerComposeDotEnv - docker-compose run phpstan - SUITE_EXIT_CODE=$? - docker-compose down - ;; - unit) - setUpDockerComposeDotEnv - docker-compose run unit - SUITE_EXIT_CODE=$? - docker-compose down - ;; - update) - # pull typo3/core-testing-*:latest versions of those ones that exist locally - docker images typo3/core-testing-*:latest --format "{{.Repository}}:latest" | xargs -I {} docker pull {} - # remove "dangling" typo3/core-testing-* images (those tagged as ) - docker images typo3/core-testing-* --filter "dangling=true" --format "{{.ID}}" | xargs -I {} docker rmi {} - ;; - *) - echo "Invalid -s option argument ${TEST_SUITE}" >&2 - echo >&2 - echo "${HELP}" >&2 - exit 1 -esac - -exit $SUITE_EXIT_CODE diff --git a/Build/phpstan-baseline-11.neon b/Build/phpstan-baseline-11.neon new file mode 100644 index 0000000..38cf700 --- /dev/null +++ b/Build/phpstan-baseline-11.neon @@ -0,0 +1,26 @@ +parameters: + ignoreErrors: + - + message: "#^Access to constant ERROR on an unknown class TYPO3\\\\CMS\\\\Core\\\\Type\\\\ContextualFeedbackSeverity\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Access to constant OK on an unknown class TYPO3\\\\CMS\\\\Core\\\\Type\\\\ContextualFeedbackSeverity\\.$#" + count: 2 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Access to constant WARNING on an unknown class TYPO3\\\\CMS\\\\Core\\\\Type\\\\ContextualFeedbackSeverity\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Backend\\\\Template\\\\ModuleTemplate\\:\\:renderResponse\\(\\)\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\View\\\\ViewInterface\\:\\:setTemplateRootPaths\\(\\)\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php diff --git a/Build/phpstan-baseline-12.neon b/Build/phpstan-baseline-12.neon new file mode 100644 index 0000000..4b906d5 --- /dev/null +++ b/Build/phpstan-baseline-12.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplateRootPaths\\(\\)\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php diff --git a/Build/phpstan-baseline-13.neon b/Build/phpstan-baseline-13.neon new file mode 100644 index 0000000..75268c4 --- /dev/null +++ b/Build/phpstan-baseline-13.neon @@ -0,0 +1,31 @@ +parameters: + ignoreErrors: + - + message: "#^Access to undefined constant TYPO3\\\\CMS\\\\Core\\\\Messaging\\\\AbstractMessage\\:\\:ERROR\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Access to undefined constant TYPO3\\\\CMS\\\\Core\\\\Messaging\\\\AbstractMessage\\:\\:OK\\.$#" + count: 2 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Access to undefined constant TYPO3\\\\CMS\\\\Core\\\\Messaging\\\\AbstractMessage\\:\\:WARNING\\.$#" + count: 2 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Backend\\\\Template\\\\ModuleTemplate\\:\\:renderContent\\(\\)\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Backend\\\\Template\\\\ModuleTemplate\\:\\:setContent\\(\\)\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php + + - + message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\View\\\\ViewInterface\\|TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplateRootPaths\\(\\)\\.$#" + count: 1 + path: ../Classes/Controller/ManagementController.php diff --git a/Build/phpstan11.neon b/Build/phpstan11.neon index 99b668e..4b7c412 100644 --- a/Build/phpstan11.neon +++ b/Build/phpstan11.neon @@ -1,3 +1,5 @@ +includes: + - phpstan-baseline-11.neon parameters: level: 5 diff --git a/Build/phpstan12.neon b/Build/phpstan12.neon index 1b5e587..4077d1c 100644 --- a/Build/phpstan12.neon +++ b/Build/phpstan12.neon @@ -1,3 +1,5 @@ +includes: + - phpstan-baseline-12.neon parameters: level: 5 diff --git a/Build/phpstan13.neon b/Build/phpstan13.neon new file mode 100644 index 0000000..03018fe --- /dev/null +++ b/Build/phpstan13.neon @@ -0,0 +1,10 @@ +includes: + - phpstan-baseline-13.neon +parameters: + level: 5 + + paths: + - %currentWorkingDirectory%/Classes + + ignoreErrors: + diff --git a/Build/testing-docker/docker-compose.yml b/Build/testing-docker/docker-compose.yml deleted file mode 100644 index 5f8319c..0000000 --- a/Build/testing-docker/docker-compose.yml +++ /dev/null @@ -1,208 +0,0 @@ -version: '2.3' -services: - chrome: - image: selenium/standalone-chrome:91.0 - tmpfs: - - /dev/shm:rw,nosuid,nodev,noexec,relatime - - mariadb10: - image: mariadb:10 - environment: - MYSQL_ROOT_PASSWORD: funcp - tmpfs: - - /var/lib/mysql/:rw,noexec,nosuid - - mssql2019latest: - image: typo3/core-testing-mssql2019:latest - environment: - ACCEPT_EULA: Y - SA_PASSWORD: "Test1234!" - MSSQL_PID: Developer - - postgres10: - image: postgres:10 - environment: - POSTGRES_PASSWORD: funcp - POSTGRES_USER: ${HOST_USER} - tmpfs: - - /var/lib/postgresql/data:rw,noexec,nosuid - - web: - image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest - user: ${HOST_UID} - stop_grace_period: 1s - volumes: - - ${ROOT_DIR}:${ROOT_DIR} - - /etc/passwd:/etc/passwd:ro - - /etc/group:/etc/group:ro - environment: - TYPO3_PATH_ROOT: ${ROOT_DIR}/.Build/Web/typo3temp/var/tests/acceptance - TYPO3_PATH_APP: ${ROOT_DIR}/.Build/Web/typo3temp/var/tests/acceptance - command: > - /bin/sh -c " - if [ ${PHP_XDEBUG_ON} -eq 0 ]; then - XDEBUG_MODE=\"off\" \ - php -S web:8000 -t ${ROOT_DIR}/.Build/Web - else - DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'` - XDEBUG_MODE=\"debug,develop\" \ - XDEBUG_TRIGGER=\"foo\" \ - XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \ - php -S web:8000 -t ${ROOT_DIR}/.Build/Web - fi - " - - cgl: - image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest - user: "${HOST_UID}" - volumes: - - ${ROOT_DIR}:${ROOT_DIR} - working_dir: ${ROOT_DIR} - command: > - /bin/sh -c " - if [ ${SCRIPT_VERBOSE} -eq 1 ]; then - set -x - fi - php -dxdebug.mode=off .Build/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix -v ${CGLCHECK_DRY_RUN} \ - --config=Build/php-cs-fixer.php --using-cache=no - " - - composer_install: - image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest - user: ${HOST_UID} - volumes: - - ${ROOT_DIR}:${ROOT_DIR} - - ${HOST_HOME}:${HOST_HOME} - - /etc/passwd:/etc/passwd:ro - - /etc/group:/etc/group:ro - working_dir: ${ROOT_DIR} - command: > - /bin/sh -c " - if [ ${SCRIPT_VERBOSE} -eq 1 ]; then - set -x - fi - php -v | grep '^PHP'; - if [ ${TYPO3} -eq 11 ]; then - composer install --no-progress --no-interaction; - else - composer remove typo3/cms* --dev --no-progress --no-interaction && composer require typo3/cms-frontend:^12.4 typo3/cms-backend:^12.4 --dev -W --no-progress --no-interaction - fi - " - - composer_validate: - image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest - user: ${HOST_UID} - volumes: - - ${ROOT_DIR}:${ROOT_DIR} - - ${HOST_HOME}:${HOST_HOME} - - /etc/passwd:/etc/passwd:ro - - /etc/group:/etc/group:ro - working_dir: ${ROOT_DIR} - command: > - /bin/sh -c " - if [ ${SCRIPT_VERBOSE} -eq 1 ]; then - set -x - fi - php -v | grep '^PHP'; - composer validate; - " - - functional_mariadb10: - image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest - user: ${HOST_UID} - links: - - mariadb10 - volumes: - - ${ROOT_DIR}:${ROOT_DIR} - - ${HOST_HOME}:${HOST_HOME} - - /etc/passwd:/etc/passwd:ro - - /etc/group:/etc/group:ro - environment: - typo3DatabaseName: func_test - typo3DatabaseUsername: root - typo3DatabasePassword: funcp - typo3DatabaseHost: mariadb10 - working_dir: ${ROOT_DIR}/.Build - command: > - /bin/sh -c " - if [ ${SCRIPT_VERBOSE} -eq 1 ]; then - set -x - fi - echo Waiting for database start...; - while ! nc -z mariadb10 3306; do - sleep 1; - done; - echo Database is up; - php -v | grep '^PHP'; - if [ ${PHP_XDEBUG_ON} -eq 0 ]; then - export XDEBUG_MODE=\"off\" - bin/phpunit -c Web/typo3conf/ext/proxycachemanager/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; - else - DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'` - export XDEBUG_MODE=\"debug,develop\" \ - XDEBUG_TRIGGER=\"foo\" \ - XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" - bin/phpunit -c Web/typo3conf/ext/proxycachemanager/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; - fi - " - lint: - image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest - user: ${HOST_UID} - volumes: - - ${ROOT_DIR}:${ROOT_DIR} - - /etc/passwd:/etc/passwd:ro - - /etc/group:/etc/group:ro - working_dir: ${ROOT_DIR} - command: > - /bin/sh -c " - if [ ${SCRIPT_VERBOSE} -eq 1 ]; then - set -x - fi - php -v | grep '^PHP'; - find . -name \\*.php ! -path "./.Build/\\*" -print0 | xargs -0 -n1 -P4 php -dxdebug.mode=off -l >/dev/null - " - - phpstan: - image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest - user: ${HOST_UID} - volumes: - - ${ROOT_DIR}:${ROOT_DIR} - - ${HOST_HOME}:${HOST_HOME} - - /etc/passwd:/etc/passwd:ro - - /etc/group:/etc/group:ro - working_dir: ${ROOT_DIR} - command: > - /bin/sh -c " - if [ ${SCRIPT_VERBOSE} -eq 1 ]; then - set -x - fi - php -v | grep '^PHP'; - php -dxdebug.mode=off .Build/bin/phpstan analyze -c Build/phpstan${TYPO3}.neon --no-progress --no-interaction - " - - unit: - image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest - user: ${HOST_UID} - volumes: - - ${ROOT_DIR}:${ROOT_DIR} - - ${HOST_HOME}:${HOST_HOME} - - /etc/passwd:/etc/passwd:ro - - /etc/group:/etc/group:ro - working_dir: ${ROOT_DIR}/.Build - command: > - /bin/sh -c " - if [ ${SCRIPT_VERBOSE} -eq 1 ]; then - set -x - fi - php -v | grep '^PHP'; - if [ ${PHP_XDEBUG_ON} -eq 0 ]; then - XDEBUG_MODE=\"off\" \ - bin/phpunit -c Web/typo3conf/ext/proxycachemanager/Build/phpunit/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; - else - DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'` - XDEBUG_MODE=\"debug,develop\" \ - XDEBUG_TRIGGER=\"foo\" \ - XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \ - bin/phpunit -c Web/typo3conf/ext/proxycachemanager/Build/phpunit/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; - fi - " diff --git a/Classes/Controller/ManagementController.php b/Classes/Controller/ManagementController.php index c685c3e..e645302 100644 --- a/Classes/Controller/ManagementController.php +++ b/Classes/Controller/ManagementController.php @@ -23,8 +23,9 @@ use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Http\RedirectResponse; +use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Messaging\AbstractMessage; -use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -40,8 +41,14 @@ public function __construct(protected ModuleTemplateFactory $moduleTemplateFacto public function indexAction(): ResponseInterface { $moduleTemplate = $this->moduleTemplateFactory->create($this->request); - $moduleTemplate->setContent($this->view->render()); - return $this->htmlResponse($moduleTemplate->renderContent()); + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) { + $this->view->setTemplateRootPaths(['EXT:proxycachemanager/Resources/Private/TemplatesV11/']); + $moduleTemplate->setContent($this->view->render()); + $response = $this->htmlResponse($moduleTemplate->renderContent()); + } else { + $response = $moduleTemplate->renderResponse('Management/Index'); + } + return $response; } /** @@ -50,10 +57,15 @@ public function indexAction(): ResponseInterface public function clearTagAction(string $tag): ResponseInterface { GeneralUtility::makeInstance(CacheManager::class)->flushCachesByTags([htmlspecialchars($tag)]); + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) { + $severity = AbstractMessage::OK; + } else { + $severity = ContextualFeedbackSeverity::OK; + } $this->addFlashMessage( 'Successfully purged cache tag "' . htmlspecialchars($tag) . '".', 'Cache flushed', - AbstractMessage::OK + $severity ); return new RedirectResponse($this->uriBuilder->reset()->uriFor('index')); } @@ -64,6 +76,11 @@ public function clearTagAction(string $tag): ResponseInterface public function purgeUrlAction(string $url): ResponseInterface { if (empty($url)) { + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) { + $severity = AbstractMessage::WARNING; + } else { + $severity = ContextualFeedbackSeverity::WARNING; + } $this->addFlashMessage( 'Please specify url', 'Cache not flushed', @@ -73,19 +90,29 @@ public function purgeUrlAction(string $url): ResponseInterface } $url = htmlspecialchars($url); if (!$this->proxyProvider->isActive()) { + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) { + $severity = AbstractMessage::ERROR; + } else { + $severity = ContextualFeedbackSeverity::ERROR; + } $this->addFlashMessage( 'Attempting to purge URL "' . $url . '". No active provider configured.', 'Cache not flushed', - AbstractMessage::ERROR + $severity ); return new RedirectResponse($this->uriBuilder->reset()->uriFor('index')); } $this->proxyProvider->flushCacheForUrls([$url]); + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) { + $severity = AbstractMessage::OK; + } else { + $severity = ContextualFeedbackSeverity::OK; + } $this->addFlashMessage( 'Successfully purged URL "' . $url . '".', 'Cache flushed', - FlashMessage::OK + $severity ); return new RedirectResponse($this->uriBuilder->reset()->uriFor('index')); } diff --git a/Classes/ProxyConfiguration.php b/Classes/ProxyConfiguration.php index df733b5..9b24db5 100755 --- a/Classes/ProxyConfiguration.php +++ b/Classes/ProxyConfiguration.php @@ -33,7 +33,7 @@ public function getProxyProvider(): ProxyProviderInterface { if ($this->proxyProvider === null) { $configuration = (GeneralUtility::makeInstance(ExtensionConfiguration::class))->get('proxycachemanager'); - if (isset($configuration['reverseProxyProvider'])) { + if (!empty($configuration['reverseProxyProvider'])) { if (!class_exists($configuration['reverseProxyProvider'])) { throw new \InvalidArgumentException('no such class ' . $configuration['reverseProxyProvider'], 1692699940); } diff --git a/Resources/Private/Templates/Management/Index.html b/Resources/Private/Templates/Management/Index.html index c9a78b8..a7d4cf8 100644 --- a/Resources/Private/Templates/Management/Index.html +++ b/Resources/Private/Templates/Management/Index.html @@ -1,4 +1,10 @@ - + + + + + @@ -19,5 +25,5 @@

Purge by URL


- +
diff --git a/Resources/Private/TemplatesV11/Management/Index.html b/Resources/Private/TemplatesV11/Management/Index.html new file mode 100644 index 0000000..c9a78b8 --- /dev/null +++ b/Resources/Private/TemplatesV11/Management/Index.html @@ -0,0 +1,23 @@ + + + + +

CDN Cache Management

+ +
+ +

Purge by URL

+
+
+ +
+ + +
+ +
+
+
+
+ + diff --git a/composer.json b/composer.json index 4d07f9d..698c1d7 100644 --- a/composer.json +++ b/composer.json @@ -30,8 +30,8 @@ "typo3/cms-frontend": "^11.5 || ^12.4 || ^13.4" }, "require-dev": { - "saschaegerer/phpstan-typo3": "^1.8", - "typo3/coding-standards": "^0.7", + "saschaegerer/phpstan-typo3": "^1.10", + "typo3/coding-standards": "^0.7 || ^0.8", "typo3/tailor": "^1.0" }, "extra": { diff --git a/ext_tables.php b/ext_tables.php index bbb3516..08e6014 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -3,9 +3,13 @@ defined('TYPO3') or die(); use B13\Proxycachemanager\ProxyConfiguration; +use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; -if ((GeneralUtility::makeInstance(ProxyConfiguration::class))->showBackendModule()) { +if ( + (GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12 && + (GeneralUtility::makeInstance(ProxyConfiguration::class))->showBackendModule() +) { \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( 'proxycachemanager', 'site',