Skip to content

Commit 986526a

Browse files
benjaminkottbuchmarvbnfhahnmgclaude
committed
[!!!][FEATURE] Support TYPO3 v13 and v14 in one version
The extension was last released as 10.0.4 in 2021. The v11 and v12 work on develop was never tagged, and two unmerged branches carried an unfinished migration to site sets. This brings all of it to one version that serves TYPO3 13.4 LTS and TYPO3 14 together, on PHP 8.2 and up. One version can serve both because the API this extension uses is the same on either: the settings API, BeforeJavaScriptsRenderingEvent, ResolveJavaScriptImportEvent and the AsEventListener attribute are unchanged between 13.4 and 14.3, and both require PHP 8.2. The one real difference is Fluid 4 against Fluid 5, which the ViewHelper handles. Configuration moves from TypoScript to site sets ------------------------------------------------ The static template is gone. Sites include the site set t3g/usercentrics and configure the extension in their site settings, which is also what made the extension work on v14 at all, because TypoScriptFrontendController was removed there. A settings type "uc_file" with a backend editor component lets the scripts be maintained in the site settings module rather than in YAML alone. The identifier argument of the script ViewHelper is now used as the AssetCollector identifier. It was a required argument that had no effect, so calling the ViewHelper twice with the same identifier now injects the script once, which is what the argument always documented. Defects fixed along the way --------------------------- * A site that does not include the site set answered HTTP 500 on every page, because an absent settingsId failed the identifier check and threw InvalidArgumentException 1583774571. * An empty settingsId passed that same check and rendered a script tag with an empty ID instead of reporting the misconfiguration. * Incomplete jsFiles and jsInline entries failed on an undefined array key instead of raising the documented exceptions. * Usercentrics was rendered in backend requests. * The useNonce argument was registered but never applied. It now maps to the AssetCollector option matching the running major, because v14 deprecated useNonce in favour of csp. * composer.json declares extra.typo3/cms.version and an empty providesPackages. Without both, TYPO3 v14 still evaluates ext_emconf.php and raises a deprecation. The file stays, because the TER reads it. Tests ----- 57 unit and 9 functional tests, green on TYPO3 13.4.34 with Fluid 4.6.1, on 14.3.6 with Fluid 5.3.1, and on the lowest dependency set. The functional suite renders real frontend pages through the site set and covers both documented ways of including a script; its regression test for the untouched site fails against the previous state with the exception above. CI runs both majors on PHP 8.2, 8.3 and 8.4 plus a lowest run. Development installation ------------------------ .ddev/config.yaml declares the container, the installation itself stays out of the repository. Build/usercentrics_demo is a development-only extension whose site set provides the page TypoScript and a Fluid template using the ViewHelper, so the rendering can be looked at in a browser. The install commands are in the README and were run from a clone-like state. Documentation is migrated to guides.xml, and the configuration and usage chapters are corrected: they described the removed static template, wrote YAML examples in TypoScript syntax, documented priority at the wrong level and carried a PHP example that could not run. Co-Authored-By: Marvin Buchmann <marvin.buchmann@typo3.com> Co-Authored-By: Benjamin Franzke <ben@bnf.dev> Co-Authored-By: Alexander Hahn <alexander@hahn.mg> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nr2wDgiyGJq1TAMeCSCjfA
1 parent 04c530f commit 986526a

40 files changed

Lines changed: 1916 additions & 551 deletions

File tree

.ddev/config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: ext-usercentrics
2+
type: typo3
3+
docroot: .build/public
4+
php_version: "8.3"
5+
webserver_type: apache-fpm
6+
xdebug_enabled: false
7+
additional_hostnames: []
8+
additional_fqdns: []
9+
database:
10+
type: mariadb
11+
version: "10.11"
12+
use_dns_when_possible: true
13+
composer_version: "2"
14+
web_environment:
15+
- PATH=/var/www/html/.build/bin:$PATH
16+
- TYPO3_CONTEXT=Development
17+
# Read by the functional test suite. The account needs to create one database
18+
# per test class, which is why it is root rather than the user the site runs as.
19+
- typo3DatabaseDriver=mysqli
20+
- typo3DatabaseHost=db
21+
- typo3DatabaseName=t3func
22+
- typo3DatabaseUsername=root
23+
- typo3DatabasePassword=root

.gitattributes

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
1-
# Folders
2-
/.ddev export-ignore
1+
# Files and folders that are not part of a release
32
/.github export-ignore
4-
/.vscode export-ignore
53
/Build export-ignore
64
/Tests export-ignore
5+
/.editorconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/.php-cs-fixer.dist.php export-ignore
9+
/.phplint.yml export-ignore
710

8-
# Files
9-
.editorconfig export-ignore
10-
.gitattributes export-ignore
11-
.gitignore export-ignore
12-
.travis.yaml export-ignore
13-
.php_cs.dist
14-
.phplint.yml
15-
16-
# Build
17-
package.json export-ignore
18-
webpack.config.js export-ignore
19-
yarn.lock export-ignore
20-
21-
# Enforce checkout with linux lf consistent over all plattforms
22-
*.xml text eol=lf
23-
*.html text eol=lf
11+
# Enforce checkout with linux lf consistent over all platforms
2412
*.css text eol=lf
25-
*.tmpl text eol=lf
26-
*.less text eol=lf
13+
*.html text eol=lf
2714
*.js text eol=lf
2815
*.json text eol=lf
16+
*.md text eol=lf
2917
*.php text eol=lf
3018
*.rst text eol=lf
31-
*.md text eol=lf
32-
*.yml text eol=lf
33-
*.ts text eol=lf
34-
*.xlf text eol=lf
3519
*.sql text eol=lf
36-
*.t3s text eol=lf
20+
*.svg text eol=lf
21+
*.tsconfig text eol=lf
3722
*.txt text eol=lf
3823
*.typoscript text eol=lf
39-
*.tsconfig text eol=lf
24+
*.xlf text eol=lf
25+
*.xml text eol=lf
26+
*.yaml text eol=lf
27+
*.yml text eol=lf

.github/workflows/ci.yml

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,81 @@
11
name: CI
22

3-
on: [push]
3+
on:
4+
push:
5+
pull_request:
46

57
jobs:
6-
build:
8+
cgl:
9+
name: CGL and lint
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: '8.2'
18+
coverage: none
19+
20+
- name: Validate composer.json
21+
run: composer validate --strict --no-check-lock
22+
23+
- name: Install dependencies
24+
run: composer install --no-progress --ansi
725

26+
- name: Install dev tools
27+
run: |
28+
for tool in `ls -1 Build/tools`; do
29+
composer install --working-dir="Build/tools/$tool" --no-progress --ansi
30+
done
31+
32+
- name: CGL
33+
run: composer t3g:cgl
34+
35+
- name: Lint PHP
36+
run: composer t3g:test:php:lint
37+
38+
tests:
39+
name: TYPO3 ${{ matrix.typo3 }} on PHP ${{ matrix.php }} (${{ matrix.dependencies }})
840
runs-on: ubuntu-latest
941
strategy:
1042
fail-fast: false
1143
matrix:
12-
typo3: [^13.4]
44+
typo3: ['^13.4', '^14.3']
1345
php: ['8.2', '8.3', '8.4']
46+
dependencies: ['highest']
1447
include:
15-
- typo3: ^13.4
48+
# Proves the lower bound the extension declares for TYPO3 v13.
49+
- typo3: '^13.4'
1650
php: '8.2'
17-
- typo3: ^13.4
18-
php: '8.3'
19-
- typo3: ^13.4
20-
php: '8.4'
51+
dependencies: 'lowest'
2152

2253
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Setup PHP ${{ matrix.php }}
26-
uses: shivammathur/setup-php@v2
27-
with:
28-
php-version: ${{ matrix.php }}
29-
30-
- name: Validate composer.json and composer.lock
31-
run: composer validate
54+
- uses: actions/checkout@v5
3255

33-
- name: Install dependencies
34-
run: |
35-
composer require typo3/cms-core:${{ matrix.typo3 }} --no-progress --ansi
36-
git checkout composer.json
56+
- name: Setup PHP ${{ matrix.php }}
57+
uses: shivammathur/setup-php@v2
58+
with:
59+
php-version: ${{ matrix.php }}
60+
extensions: pdo_sqlite, sqlite3
61+
coverage: none
3762

38-
- name: Install dev tools
39-
run: |
40-
for tool in `ls -1 Build/tools`; do
41-
composer install --working-dir="Build/tools/$tool" --no-progress --ansi
42-
done
63+
- name: Install dependencies
64+
run: |
65+
composer update \
66+
--with "typo3/cms-core:${{ matrix.typo3 }}" \
67+
${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }} \
68+
--no-progress --ansi
4369
44-
- name: CGL
45-
run: composer t3g:cgl
70+
# Informational only: "composer show" takes a single package, and a
71+
# diagnostic step must not be able to fail the build.
72+
- name: Show installed versions
73+
run: composer show --locked
4674

47-
- name: Lint PHP
48-
run: composer t3g:test:php:lint
75+
- name: Unit Tests
76+
run: composer t3g:test:php:unit
4977

50-
- name: Unit Tests
51-
run: composer t3g:test:php:unit
78+
- name: Functional Tests
79+
env:
80+
typo3DatabaseDriver: pdo_sqlite
81+
run: composer t3g:test:php:functional

.github/workflows/publish.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: publish
32

43
on:
@@ -10,41 +9,46 @@ jobs:
109
publish:
1110
name: Publish new version to TER
1211
if: startsWith(github.ref, 'refs/tags/')
13-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-latest
1413
env:
1514
TYPO3_EXTENSION_KEY: ${{ secrets.TYPO3_EXTENSION_KEY }}
1615
TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }}
1716

1817
steps:
1918
- name: Checkout repository
20-
uses: actions/checkout@v2
19+
uses: actions/checkout@v5
20+
with:
21+
fetch-depth: 0
2122

2223
- name: Check tag
2324
run: |
24-
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
25+
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
26+
echo "Tag ${{ github.ref }} is not a valid TER version number."
2527
exit 1
2628
fi
29+
2730
- name: Get version
2831
id: get-version
29-
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
32+
run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
3033

3134
- name: Get comment
3235
id: get-comment
3336
run: |
34-
readonly local comment=$(git tag -n10 -l ${{ steps.get-version.outputs.version }} | sed "s/^[0-9.]*[ ]*//g")
37+
comment=$(git tag -n10 -l "${{ steps.get-version.outputs.version }}" | sed "s/^[0-9.]*[ ]*//g")
3538
if [[ -z "${comment// }" ]]; then
36-
echo ::set-output name=comment::Released version ${{ steps.get-version.outputs.version }} of ${{ env.TYPO3_EXTENSION_KEY }}
37-
else
38-
echo ::set-output name=comment::$comment
39+
comment="Released version ${{ steps.get-version.outputs.version }} of ${TYPO3_EXTENSION_KEY}"
3940
fi
41+
echo "comment=${comment}" >> "$GITHUB_OUTPUT"
42+
4043
- name: Setup PHP
4144
uses: shivammathur/setup-php@v2
4245
with:
43-
php-version: 8.0
46+
php-version: '8.3'
4447
extensions: intl, mbstring, json, zip, curl
48+
coverage: none
4549

4650
- name: Install tailor
47-
run: composer global require typo3/tailor --prefer-dist --no-progress --no-suggest
51+
run: composer global require typo3/tailor --prefer-dist --no-progress
4852

4953
- name: Publish to TER
50-
run: php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ steps.get-comment.outputs.comment }}" ${{ steps.get-version.outputs.version }}
54+
run: php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ steps.get-comment.outputs.comment }}" "${{ steps.get-version.outputs.version }}"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ composer.lock
1414
.build/
1515
.ddev/**/*.example
1616
.ddev/**/*.txt
17-
.ddev/commands/
17+
Build/.phpunit.cache/
1818
Build/.phpunit.result.cache
1919
Documentation-GENERATED-temp/
2020
node_modules/
2121
var/
22+
23+
# The installation TYPO3 writes below the Composer root
2224
config/
2325

2426
# CGL Fixer
Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
<?php
22

3-
/**
4-
* This file represents the configuration for Code Sniffing PSR-2-related
5-
* automatic checks of coding guidelines
6-
* Install @fabpot's great php-cs-fixer tool via
7-
*
8-
* $ composer global require friendsofphp/php-cs-fixer
9-
*
10-
* And then simply run
11-
*
12-
* $ php-cs-fixer fix
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the package t3g/usercentrics.
137
*
14-
* For more information read:
15-
* http://www.php-fig.org/psr/psr-2/
16-
* http://cs.sensiolabs.org
8+
* For the full copyright and license information, please read the
9+
* LICENSE file that was distributed with this source code.
1710
*/
1811

1912
if (PHP_SAPI !== 'cli') {
@@ -31,41 +24,39 @@
3124
->setRiskyAllowed(true)
3225
->setRules([
3326
'@PSR2' => true,
34-
'header_comment' => [
35-
'header' => $header
36-
],
37-
'general_phpdoc_annotation_remove' => [
38-
'annotations' => [
39-
'author'
40-
],
41-
],
27+
'array_syntax' => ['syntax' => 'short'],
28+
'concat_space' => ['spacing' => 'one'],
29+
'declare_equal_normalize' => ['space' => 'none'],
30+
'general_phpdoc_annotation_remove' => ['annotations' => ['author']],
31+
'header_comment' => ['header' => $header],
32+
'lowercase_cast' => true,
33+
'native_function_casing' => true,
34+
'no_alias_functions' => true,
35+
'no_blank_lines_after_phpdoc' => true,
36+
'no_empty_statement' => true,
37+
'no_extra_blank_lines' => true,
4238
'no_leading_import_slash' => true,
43-
'no_trailing_comma_in_singleline' => true,
39+
'no_leading_namespace_whitespace' => true,
40+
'no_short_bool_cast' => true,
4441
'no_singleline_whitespace_before_semicolons' => true,
42+
'no_trailing_comma_in_singleline' => true,
43+
'no_unneeded_control_parentheses' => true,
4544
'no_unused_imports' => true,
46-
'concat_space' => ['spacing' => 'one'],
4745
'no_whitespace_in_blank_line' => true,
4846
'ordered_imports' => true,
49-
'single_quote' => true,
50-
'no_empty_statement' => true,
51-
'no_extra_blank_lines' => true,
5247
'phpdoc_no_package' => true,
5348
'phpdoc_scalar' => true,
54-
'no_blank_lines_after_phpdoc' => true,
55-
'array_syntax' => ['syntax' => 'short'],
56-
'whitespace_after_comma_in_array' => true,
57-
'function_typehint_space' => true,
58-
'single_line_comment_style' => true,
59-
'no_alias_functions' => true,
60-
'lowercase_cast' => true,
61-
'no_leading_namespace_whitespace' => true,
62-
'native_function_casing' => true,
6349
'self_accessor' => true,
64-
'no_short_bool_cast' => true,
65-
'no_unneeded_control_parentheses' => true
50+
'single_line_comment_style' => true,
51+
'single_quote' => true,
52+
'type_declaration_spaces' => true,
53+
'whitespace_after_comma_in_array' => true,
6654
])
6755
->setFinder(
6856
PhpCsFixer\Finder::create()
6957
->exclude('.build')
58+
->exclude('Build/tools')
59+
->exclude('config')
60+
->exclude('var')
7061
->in(__DIR__)
7162
);

.phplint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ extensions:
66
exclude:
77
- .build
88
- Build
9+
- config
10+
- var

Build/FunctionalTests.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="../.build/vendor/phpunit/phpunit/phpunit.xsd"
5+
backupGlobals="true"
6+
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
7+
cacheDirectory=".phpunit.cache"
8+
cacheResult="false"
9+
colors="true"
10+
displayDetailsOnTestsThatTriggerDeprecations="true"
11+
displayDetailsOnTestsThatTriggerErrors="true"
12+
displayDetailsOnTestsThatTriggerNotices="true"
13+
displayDetailsOnTestsThatTriggerWarnings="true"
14+
failOnDeprecation="true"
15+
failOnNotice="true"
16+
failOnRisky="true"
17+
failOnWarning="true"
18+
requireCoverageMetadata="false"
19+
>
20+
<testsuites>
21+
<testsuite name="Usercentrics Extension">
22+
<directory>../Tests/Functional/</directory>
23+
</testsuite>
24+
</testsuites>
25+
<php>
26+
<ini name="display_errors" value="1"/>
27+
<env name="TYPO3_CONTEXT" value="Testing"/>
28+
</php>
29+
</phpunit>

0 commit comments

Comments
 (0)