diff --git a/.github/workflows/core11.yml b/.github/workflows/core13.yml similarity index 56% rename from .github/workflows/core11.yml rename to .github/workflows/core13.yml index 495cc74..1c0bc45 100644 --- a/.github/workflows/core11.yml +++ b/.github/workflows/core13.yml @@ -1,33 +1,30 @@ -name: core 11 +name: core 13 on: [ push, pull_request ] jobs: tests: - name: v11 + name: v13 runs-on: ubuntu-20.04 strategy: # This prevents cancellation of matrix job runs, if one/two already failed and let the # rest matrix jobs be executed anyway. fail-fast: false matrix: - php: [ '7.4', '8.0', '8.1', '8.2' ] + php: [ '8.2', '8.3' ] composerInstall: [ 'composerInstallLowest', 'composerInstallHighest' ] steps: - name: Checkout uses: actions/checkout@v3 - - name: Validate composer.json and composer.lock - run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -s composer -e 'validate' - - name: Install testing system - run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -s ${{ matrix.composerInstall }} + run: Build/Scripts/runTests.sh -t 13 -p ${{ matrix.php }} -s ${{ matrix.composerInstall }} - name: Lint PHP - run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -s lint + run: Build/Scripts/runTests.sh -t 13 -p ${{ matrix.php }} -s lint - name: Validate code against CGL - run: PHP_CS_FIXER_IGNORE_ENV=1 Build/Scripts/runTests.sh -t 11 -p 8.2 -s cgl -n + run: PHP_CS_FIXER_IGNORE_ENV=1 Build/Scripts/runTests.sh -t 13 -p 8.3 -s cgl -n - name: Unit Tests - run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -s unit + run: Build/Scripts/runTests.sh -t 13 -p ${{ matrix.php }} -s unit diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index d98f722..dce8bb6 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -45,8 +45,8 @@ handleDbmsOptions() { echo "Use \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2 exit 1 fi - [ -z "${DBMS_VERSION}" ] && DBMS_VERSION="10.2" - if ! [[ ${DBMS_VERSION} =~ ^(10.2|10.3|10.4|10.5|10.6|10.7|10.8|10.9|10.10|10.11|11.0|11.1)$ ]]; then + [ -z "${DBMS_VERSION}" ] && DBMS_VERSION="10.3" + if ! [[ ${DBMS_VERSION} =~ ^(10.3|10.4|10.5|10.6|10.7|10.8|10.9|10.10|10.11|11.0|11.1)$ ]]; then echo "Invalid combination -d ${DBMS} -i ${DBMS_VERSION}" >&2 echo >&2 echo "Use \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2 @@ -61,8 +61,8 @@ handleDbmsOptions() { echo "Use \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2 exit 1 fi - [ -z "${DBMS_VERSION}" ] && DBMS_VERSION="5.5" - if ! [[ ${DBMS_VERSION} =~ ^(5.5|5.6|5.7|8.0)$ ]]; then + [ -z "${DBMS_VERSION}" ] && DBMS_VERSION="8.0" + if ! [[ ${DBMS_VERSION} =~ ^(8.0)$ ]]; then echo "Invalid combination -d ${DBMS} -i ${DBMS_VERSION}" >&2 echo >&2 echo "Use \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2 @@ -170,6 +170,7 @@ Options: - composerInstallHighest: "composer update", handy if host has no PHP - coveralls: Generate coverage - docsGenerate: Renders the extension ReST documentation. + - rector: Run rector - functional: functional tests - lint: PHP linting - unit: PHP unit tests @@ -200,8 +201,7 @@ Options: -i version Specify a specific database version With "-d mariadb": - - 10.2 short-term, maintained until 2023-05-25 (default) - - 10.3 short-term, maintained until 2023-05-25 + - 10.3 short-term, maintained until 2023-05-25 (default) - 10.4 short-term, maintained until 2024-06-18 - 10.5 short-term, maintained until 2025-06-24 - 10.6 long-term, maintained until 2026-06 @@ -213,10 +213,7 @@ Options: - 11.0 development series - 11.1 short-term development series With "-d mysql": - - 5.5 unmaintained since 2018-12 (default) - - 5.6 unmaintained since 2021-02 - - 5.7 maintained until 2023-10 - - 8.0 maintained until 2026-04 + - 8.0 maintained until 2026-04 (default) With "-d postgres": - 10 unmaintained since 2022-11-10 (default) - 11 unmaintained since 2023-11-09 @@ -226,19 +223,18 @@ Options: - 15 maintained until 2027-11-11 - 16 maintained until 2028-11-09 - -t <11|12> + -t <12|13> Only with -s composerInstall|composerInstallMin|composerInstallMax Specifies the TYPO3 CORE Version to be used - - 11.5: use TYPO3 v11 (default) - - 12.4: use TYPO3 v12 + - 12: use TYPO3 v12 (default) + - 13: use TYPO3 v13 - -p <7.4|8.0|8.1|8.2|8.3> + -p <8.1|8.2|8.3|8.4> Specifies the PHP minor version to be used - - 7.4: use PHP 7.4 (default) - - 8.0: use PHP 8.0 - - 8.1: use PHP 8.1 + - 8.1: use PHP 8.1 (default) - 8.2: use PHP 8.2 - 8.3: use PHP 8.3 + - 8.4: use PHP 8.4 -e "" Only with -s docsGenerate|functional|unit @@ -275,7 +271,7 @@ Options: Show this help. Examples: - # Run all core unit tests using PHP 7.4 + # Run all core unit tests ./Build/Scripts/runTests.sh -s unit # Run all core units tests and enable xdebug (have a PhpStorm listening on port 9003!) @@ -311,23 +307,23 @@ ROOT_DIR="${PWD}" # Option defaults TEST_SUITE="" -TYPO3_VERSION="11" +TYPO3_VERSION="12" DBMS="sqlite" DBMS_VERSION="" -PHP_VERSION="7.4" +PHP_VERSION="8.1" PHP_XDEBUG_ON=0 PHP_XDEBUG_PORT=9003 EXTRA_TEST_OPTIONS="" -CGLCHECK_DRY_RUN=0 +DRY_RUN=0 DATABASE_DRIVER="" CONTAINER_BIN="" -COMPOSER_ROOT_VERSION="11.4.3-dev" +COMPOSER_ROOT_VERSION="12.0.0-dev" CONTAINER_INTERACTIVE="-it --init" HOST_UID=$(id -u) HOST_PID=$(id -g) USERSET="" SUFFIX=$(echo $RANDOM) -NETWORK="friendsoftypo3-tea-${SUFFIX}" +NETWORK="georgringer-news-${SUFFIX}" CI_PARAMS="${CI_PARAMS:-}" CONTAINER_HOST="host.docker.internal" PHPSTAN_CONFIG_FILE="phpstan.neon" @@ -361,7 +357,7 @@ while getopts "a:b:s:d:i:p:e:t:xy:nhu" OPT; do ;; p) PHP_VERSION=${OPTARG} - if ! [[ ${PHP_VERSION} =~ ^(7.4|8.0|8.1|8.2|8.3)$ ]]; then + if ! [[ ${PHP_VERSION} =~ ^(8.1|8.2|8.3|8.4)$ ]]; then INVALID_OPTIONS+=("-p ${OPTARG}") fi ;; @@ -370,7 +366,7 @@ while getopts "a:b:s:d:i:p:e:t:xy:nhu" OPT; do ;; t) TYPO3_VERSION=${OPTARG} - if ! [[ ${TYPO3_VERSION} =~ ^(11|12)$ ]]; then + if ! [[ ${TYPO3_VERSION} =~ ^(12|13)$ ]]; then INVALID_OPTIONS+=("-t ${OPTARG}") fi ;; @@ -381,7 +377,7 @@ while getopts "a:b:s:d:i:p:e:t:xy:nhu" OPT; do PHP_XDEBUG_PORT=${OPTARG} ;; n) - CGLCHECK_DRY_RUN=1 + DRY_RUN=1 ;; h) loadHelp @@ -474,7 +470,7 @@ fi case ${TEST_SUITE} in cgl) DRY_RUN_OPTIONS='' - if [ "${CGLCHECK_DRY_RUN}" -eq 1 ]; then + if [ "${DRY_RUN}" -eq 1 ]; then DRY_RUN_OPTIONS='--dry-run --diff' fi COMMAND="php -dxdebug.mode=off .Build/bin/php-cs-fixer fix -v ${DRY_RUN_OPTIONS} --config=Build/php-cs-fixer/php-cs-fixer.php --using-cache=no" @@ -508,14 +504,14 @@ case ${TEST_SUITE} in cleanComposer stashComposerFiles ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-install-highest-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/bash -c " - if [ ${TYPO3_VERSION} -eq 11 ]; then - composer require --no-ansi --no-interaction --no-progress --no-install \ - typo3/cms-core:^11.5.24 || exit 1 - fi if [ ${TYPO3_VERSION} -eq 12 ]; then composer require --no-ansi --no-interaction --no-progress --no-install \ typo3/cms-core:^12.4.2 || exit 1 fi + if [ ${TYPO3_VERSION} -eq 13 ]; then + composer require --no-ansi --no-interaction --no-progress --no-install \ + typo3/cms-core:^13.1 || exit 1 + fi composer update --no-progress --no-interaction || exit 1 composer show || exit 1 " @@ -526,14 +522,14 @@ case ${TEST_SUITE} in cleanComposer stashComposerFiles ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-install-lowest-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/bash -c " - if [ ${TYPO3_VERSION} -eq 11 ]; then - composer require --no-ansi --no-interaction --no-progress --no-install \ - typo3/cms-core:^11.5.24 || exit 1 - fi if [ ${TYPO3_VERSION} -eq 12 ]; then composer require --no-ansi --no-interaction --no-progress --no-install \ typo3/cms-core:^12.4.2 || exit 1 fi + if [ ${TYPO3_VERSION} -eq 13 ]; then + composer require --no-ansi --no-interaction --no-progress --no-install \ + typo3/cms-core:^13.1 || exit 1 + fi composer update --no-ansi --no-interaction --no-progress --with-dependencies --prefer-lowest || exit 1 composer show || exit 1 " @@ -592,6 +588,15 @@ case ${TEST_SUITE} in ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/bash -c "${COMMAND}" SUITE_EXIT_CODE=$? ;; + rector) + DRY_RUN_OPTIONS='' + if [ "${DRY_RUN}" -eq 1 ]; then + DRY_RUN_OPTIONS='--dry-run' + fi + COMMAND="php -dxdebug.mode=off .Build/bin/rector process ${DRY_RUN_OPTIONS} --config=Build/rector/rector.php --no-progress-bar --ansi" + ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/sh -c "${COMMAND}" + SUITE_EXIT_CODE=$? + ;; unit) COMMAND=(.Build/bin/phpunit -c Build/phpunit/UnitTests.xml --exclude-group not-${DBMS} ${EXTRA_TEST_OPTIONS} "$@") ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name unit-${SUFFIX} ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${IMAGE_PHP} "${COMMAND[@]}" diff --git a/Build/phpunit/FunctionalTestsBootstrap.php b/Build/phpunit/FunctionalTestsBootstrap.php index a95bc52..9882f8f 100644 --- a/Build/phpunit/FunctionalTestsBootstrap.php +++ b/Build/phpunit/FunctionalTestsBootstrap.php @@ -1,4 +1,5 @@ isFormWithCaptchaField($mail) || $this->isCaptchaCheckToSkip()) { - return; - } - - $friendlyCaptchaService = GeneralUtility::makeInstance(Api::class); - if (!$friendlyCaptchaService->verify()) { - $this->addError( - $this->translateErrorMessage('message.invalid', 'friendlycaptcha_official'), - 1689157219, - ); - } - } - - protected function isFormWithCaptchaField($mail): bool - { - foreach ($mail->getForm()->getPages() as $page) { - foreach ($page->getFields() as $field) { - if ($field->getType() === 'friendlycaptcha') { - return true; - } - } - } - return false; - } - - /** - * Captcha check should be skipped on createAction if there was a confirmationAction where the captcha was - * already checked before - * Note: $this->flexForm is only available in powermail 3.9 or newer - */ - protected function isCaptchaCheckToSkip(): bool - { - if (property_exists($this, 'flexForm')) { - $confirmationActive = $this->flexForm['settings']['flexform']['main']['confirmation'] === '1'; - $optinActive = $this->flexForm['settings']['flexform']['main']['optin'] === '1'; - - return $this->getActionName() === 'create' && $confirmationActive - || $this->getActionName() === 'optinConfirm' && $optinActive; - } - return false; - } - - /** - * @return string "confirmation" or "create" - */ - protected function getActionName(): string - { - $pluginVariables = GeneralUtility::_GPmerged('tx_powermail_pi1'); - return $pluginVariables['action']; - } -} diff --git a/Classes/FieldValidator/PowermailValidator.php b/Classes/FieldValidator/PowermailValidator.php index 8fd52ca..120e733 100644 --- a/Classes/FieldValidator/PowermailValidator.php +++ b/Classes/FieldValidator/PowermailValidator.php @@ -6,39 +6,27 @@ use In2code\Powermail\Domain\Validator\AbstractValidator; use StudioMitte\FriendlyCaptcha\Service\Api; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Error\Error; -use TYPO3\CMS\Extbase\Error\Result; class PowermailValidator extends AbstractValidator { /** * @param Mail $mail - * @return Result */ - public function validate($mail): Result + public function isValid($mail): void { - $result = new Result(); if (!$this->isFormWithCaptchaField($mail) || $this->isCaptchaCheckToSkip()) { - return $result; + return; } $friendlyCaptchaService = GeneralUtility::makeInstance(Api::class); if (!$friendlyCaptchaService->verify()) { - $result->addError( - new Error( - $this->getLanguageService()->sL('LLL:EXT:friendlycaptcha_official/Resources/Private/Language/locallang.xlf:message.invalid'), - 1689157219 - ) + $this->addError( + $this->translateErrorMessage('message.invalid', 'friendlycaptcha_official'), + 1689157219, ); } - return $result; - } - - public function isValid(mixed $mail): void - { - return; } protected function isFormWithCaptchaField($mail): bool @@ -61,12 +49,18 @@ protected function isFormWithCaptchaField($mail): bool protected function isCaptchaCheckToSkip(): bool { if (property_exists($this, 'flexForm')) { + $action = $this->getActionName(); $confirmationActive = $this->flexForm['settings']['flexform']['main']['confirmation'] === '1'; $optinActive = $this->flexForm['settings']['flexform']['main']['optin'] === '1'; + if ($action === 'create' && $confirmationActive || $action === 'checkCreate' && $confirmationActive) { + return true; + } - return $this->getActionName() === 'create' && $confirmationActive - || $this->getActionName() === 'optinConfirm' && $optinActive; + if ($action === 'optinConfirm' && $optinActive) { + return true; + } } + return false; } @@ -75,12 +69,9 @@ protected function isCaptchaCheckToSkip(): bool */ protected function getActionName(): string { - $pluginVariables = GeneralUtility::_GPmerged('tx_powermail_pi1'); + $request = $GLOBALS['TYPO3_REQUEST']; + $pluginVariables = $request->getQueryParams()['tx_powermail_pi1']; + ArrayUtility::mergeRecursiveWithOverrule($pluginVariables, $request->getParsedBody()['tx_powermail_pi1']); return $pluginVariables['action']; } - - private function getLanguageService(): LanguageService - { - return $GLOBALS['LANG']; - } } diff --git a/Classes/Form/CustomFormElement.php b/Classes/Form/CustomFormElement.php index 2f47d92..9b2eb4e 100644 --- a/Classes/Form/CustomFormElement.php +++ b/Classes/Form/CustomFormElement.php @@ -10,7 +10,7 @@ class CustomFormElement extends GenericFormElement { - public function initializeFormElement() + public function initializeFormElement(): void { $this->addValidator(GeneralUtility::makeInstance(NotEmptyValidator::class)); } diff --git a/Classes/ViewHelpers/ConfigurationViewHelper.php b/Classes/ViewHelpers/ConfigurationViewHelper.php index ea05c4f..1eb4565 100644 --- a/Classes/ViewHelpers/ConfigurationViewHelper.php +++ b/Classes/ViewHelpers/ConfigurationViewHelper.php @@ -6,13 +6,10 @@ use StudioMitte\FriendlyCaptcha\Configuration; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; class ConfigurationViewHelper extends AbstractViewHelper { - use CompileWithRenderStatic; - - public static function render() + public function render(): array { $configuration = new Configuration(); return [ diff --git a/Configuration/TypoScript/Powermail/setup.typoscript b/Configuration/TypoScript/Powermail/setup.typoscript index 4c0b2b8..96dd0fe 100644 --- a/Configuration/TypoScript/Powermail/setup.typoscript +++ b/Configuration/TypoScript/Powermail/setup.typoscript @@ -15,15 +15,3 @@ plugin.tx_powermail { } } } - -[compatVersion("12.4")] - plugin.tx_powermail.settings.setup.validators { - 981818 { - class = StudioMitte\FriendlyCaptcha\FieldValidator\PowermailV11Validator - config { - # Until https://github.com/in2code-de/powermail/pull/941 is merged & released - dummy = 1 - } - } - } -[global] diff --git a/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php b/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php index 19e0626..c2f9951 100644 --- a/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php @@ -15,7 +15,7 @@ class ConfigurationViewHelperTest extends BaseTestCase /** * @test */ - public function viewHelperReturnsProperConfiguration() + public function viewHelperReturnsProperConfiguration(): void { self::setupRequest(); $configurationViewHelper = new ConfigurationViewHelper(); diff --git a/composer.json b/composer.json index f3fb2e1..2dab7f9 100644 --- a/composer.json +++ b/composer.json @@ -5,16 +5,16 @@ "homepage": "https://www.studiomitte.com", "license": "GPL-2.0-or-later", "require": { - "typo3/cms-core": "^11.5.30 || ^12.4.5" + "typo3/cms-core": "^12.4.5 || ^13.4" }, "require-dev": { "typo3/cms-composer-installers": "^3.1.3 || 4.0.0-RC1 || ^5.0", - "typo3/testing-framework": "^7.0.1", - "typo3/cms-form": "^11.5.30 || ^12.4.5", - "phpunit/phpunit": "^9", + "typo3/cms-form": "^12.4.5 || ^13.4", + "phpunit/phpunit": "^10", "typo3/coding-standards": "^0.5.3", "friendsofphp/php-cs-fixer": "^3.51.0", - "webmozart/assert": "^1.11.0" + "webmozart/assert": "^1.11.0", + "typo3/testing-framework": "^8.2" }, "suggest": { "in2code/powermail": "Support for EXT:powermail", diff --git a/ext_emconf.php b/ext_emconf.php deleted file mode 100644 index 40d3ef0..0000000 --- a/ext_emconf.php +++ /dev/null @@ -1,21 +0,0 @@ - 'Integration of Friendly Captcha', - 'description' => 'FriendlyCaptcha Integration for EXT:powermail and EXT:form and your custom implementation', - 'category' => 'plugin', - 'constraints' => [ - 'depends' => [ - 'typo3' => '11.5.0-12.9.99', - ], - 'conflicts' => [ - ], - ], - 'autoload' => [ - 'psr-4' => [ - 'StudioMitte\\FriendlyCaptcha\\' => 'Classes', - ], - ], - 'state' => 'beta', - 'version' => '1.0.0', -];