Skip to content

Commit 3102f8e

Browse files
authored
[TASK] upgrade to TYPO3v14 + drop 11 and 12 support (#57)
* [TASK] upgrade to TYPO3v14 + drop 11 and 12 support * [TASK] fix pipeline
1 parent 3322b6e commit 3102f8e

26 files changed

Lines changed: 197 additions & 802 deletions

.github/workflows/tasks.yml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,16 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php: [ '8.1', '8.2', '8.3', '8.4' ]
15-
typo3: [ '11', '12', '13' ]
14+
php: [ '8.2', '8.3', '8.4' ]
15+
typo3: [ '13', '14' ]
1616
sentry: [ false, true ]
17-
exclude:
18-
- php: '8.1'
19-
typo3: '13'
20-
sentry: true
21-
- php: '8.1'
22-
typo3: '13'
23-
sentry: false
2417
steps:
2518
- name: Setup PHP with PECL extension
2619
uses: shivammathur/setup-php@v2
2720
with:
2821
php-version: ${{ matrix.php }}
29-
# - uses: mirromutth/mysql-action@v1.1
30-
# with:
31-
# mysql version: '5.7'
32-
# mysql database: 'typo3_test'
33-
# mysql root password: 'root'
34-
- uses: actions/checkout@v4
35-
- uses: actions/cache@v4
22+
- uses: actions/checkout@v6
23+
- uses: actions/cache@v5
3624
with:
3725
path: ~/.composer/cache/files
3826
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -46,7 +34,7 @@ jobs:
4634
- run: composer test
4735
- run: jq 'del(.logs.html)' infection.json > infection.json.new && mv infection.json.new infection.json
4836
- run: composer infection
49-
- uses: codecov/codecov-action@v5
37+
- uses: codecov/codecov-action@v6
5038
with:
5139
token: ${{ secrets.CODECOV_TOKEN }}
5240
file: Resources/Public/test-result/clover.xml
@@ -64,15 +52,15 @@ jobs:
6452
TYPO3_API_PASSWORD: ${{ secrets.TYPO3_API_PASSWORD }}
6553

6654
steps:
67-
- uses: actions/checkout@v4
55+
- uses: actions/checkout@v6
6856
- name: Get the version
6957
id: get_version
7058
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
7159

7260
- name: Setup PHP
7361
uses: shivammathur/setup-php@v2
7462
with:
75-
php-version: '7.4'
63+
php-version: '8.4'
7664
extensions: intl, mbstring, xml, soap, zip, curl
7765

7866
- name: Install typo3/tailor

Classes/DataProcessor/XClassContentDataProcessor.php

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,19 @@
44

55
namespace Kanti\ServerTiming\DataProcessor;
66

7-
use TYPO3\CMS\Core\Utility\ArrayUtility;
7+
use TYPO3\CMS\Core\Information\Typo3Version;
88
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
9-
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
109

11-
final class XClassContentDataProcessor extends ContentDataProcessor
12-
{
13-
/**
14-
* @param array<array-key, mixed> $configuration
15-
* @param array<array-key, mixed> $variables
16-
* @return array<array-key, mixed>
17-
*/
18-
public function process(ContentObjectRenderer $cObject, array $configuration, array $variables)
19-
{
20-
$processors = $configuration['dataProcessing.'] ?? [];
21-
if (!$processors) {
22-
return $variables;
23-
}
24-
25-
$processorKeys = ArrayUtility::filterAndSortByNumericKeys($processors);
26-
$index = 1;
27-
$newDataProcessing = [];
28-
foreach ($processorKeys as $key) {
29-
$processorClassOrAlias = $processors[$key];
30-
31-
$uniqId = uniqId();
32-
33-
$newDataProcessing[$index] = TrackingDataProcessor::class;
34-
$newDataProcessing[$index . '.'] = ['key' => $key, 'processorOrAlias' => $processorClassOrAlias, 'type' => 'start', 'id' => $uniqId, 'for' => $cObject->getCurrentTable() . ':' . $cObject->data['uid']];
35-
$index++;
36-
$newDataProcessing[$index] = $processorClassOrAlias;
37-
$newDataProcessing[$index . '.'] = $processors[$key . '.'] ?? [];
38-
$index++;
39-
$newDataProcessing[$index] = TrackingDataProcessor::class;
40-
$newDataProcessing[$index . '.'] = ['type' => 'stop', 'id' => $uniqId];
41-
$index++;
42-
}
10+
// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
4311

44-
$configuration['dataProcessing.'] = $newDataProcessing;
45-
46-
return parent::process($cObject, $configuration, $variables);
12+
if ((new Typo3Version())->getMajorVersion() <= 13) {
13+
final class XClassContentDataProcessor extends ContentDataProcessor
14+
{
15+
use XClassContentDataProcessorTrait;
16+
}
17+
} else {
18+
final readonly class XClassContentDataProcessor extends ContentDataProcessor
19+
{
20+
use XClassContentDataProcessorTrait;
4721
}
4822
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kanti\ServerTiming\DataProcessor;
6+
7+
use TYPO3\CMS\Core\Utility\ArrayUtility;
8+
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
9+
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
10+
11+
trait XClassContentDataProcessorTrait
12+
{
13+
/**
14+
* @param array<array-key, mixed> $configuration
15+
* @param array<array-key, mixed> $variables
16+
* @return array<array-key, mixed>
17+
*/
18+
public function process(ContentObjectRenderer $cObject, array $configuration, array $variables)
19+
{
20+
$processors = $configuration['dataProcessing.'] ?? [];
21+
if (!$processors) {
22+
return $variables;
23+
}
24+
25+
$processorKeys = ArrayUtility::filterAndSortByNumericKeys($processors);
26+
$index = 1;
27+
$newDataProcessing = [];
28+
foreach ($processorKeys as $key) {
29+
$processorClassOrAlias = $processors[$key];
30+
31+
$uniqId = uniqId();
32+
33+
$newDataProcessing[$index] = TrackingDataProcessor::class;
34+
$newDataProcessing[$index . '.'] = ['key' => $key, 'processorOrAlias' => $processorClassOrAlias, 'type' => 'start', 'id' => $uniqId, 'for' => $cObject->getCurrentTable() . ':' . $cObject->data['uid']];
35+
$index++;
36+
$newDataProcessing[$index] = $processorClassOrAlias;
37+
$newDataProcessing[$index . '.'] = $processors[$key . '.'] ?? [];
38+
$index++;
39+
$newDataProcessing[$index] = TrackingDataProcessor::class;
40+
$newDataProcessing[$index . '.'] = ['type' => 'stop', 'id' => $uniqId];
41+
$index++;
42+
}
43+
44+
$configuration['dataProcessing.'] = $newDataProcessing;
45+
46+
return parent::process($cObject, $configuration, $variables);
47+
}
48+
}

Classes/Dto/ScriptResult.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
use Psr\Http\Message\ServerRequestInterface;
1010
use TYPO3\CMS\Core\Http\ServerRequestFactory;
1111

12-
final class ScriptResult
12+
final readonly class ScriptResult
1313
{
14-
private function __construct(public readonly ?ServerRequestInterface $request, public readonly ?ResponseInterface $response, public readonly ?int $cliExitCode)
15-
{
14+
private function __construct(
15+
public ?ServerRequestInterface $request,
16+
public ?ResponseInterface $response,
17+
public ?int $cliExitCode,
18+
) {
1619
}
1720

1821
public static function fromRequest(ServerRequestInterface $request, ?ResponseInterface $response = null): ScriptResult

Classes/EventListener/BootCompletedEventListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
namespace Kanti\ServerTiming\EventListener;
66

7-
use Kanti\ServerTiming\SqlLogging\SqlLoggerCore11;
87
use Kanti\ServerTiming\Utility\TimingUtility;
8+
use TYPO3\CMS\Core\Attribute\AsEventListener;
99
use TYPO3\CMS\Core\Core\Event\BootCompletedEvent;
1010

1111
final class BootCompletedEventListener
1212
{
13+
#[AsEventListener('kanti/server-timing/boot-completed-event-listener')]
1314
public function __invoke(BootCompletedEvent $event): void
1415
{
1516
// we initialize TimingUtility here
1617
// in the install tool, (eg. DB compare)
1718
// at this point, the TimingUtility is found in the container, but at the shutdown state the TimingUtility is not found in the container.
1819
// so if we initialize it right here and save it inside a static variable, then everything works as expected. (not the sentry part :/ )
1920
TimingUtility::getInstance();
20-
SqlLoggerCore11::registerSqlLogger();
2121
}
2222
}

Classes/EventListener/ConsoleCommandEventListener.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@
66

77
use Exception;
88
use Kanti\ServerTiming\Dto\ScriptResult;
9+
use Kanti\ServerTiming\Dto\StopWatch;
910
use Kanti\ServerTiming\Utility\TimingUtility;
1011
use Symfony\Component\Console\Event\ConsoleCommandEvent;
1112
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
12-
use Kanti\ServerTiming\Dto\StopWatch;
13+
use Symfony\Component\Console\Output\OutputInterface;
14+
use TYPO3\CMS\Core\Attribute\AsEventListener;
1315

1416
final class ConsoleCommandEventListener
1517
{
1618
/** @var StopWatch[] */
1719
private array $stopWatches = [];
1820

21+
#[AsEventListener('kanti/server-timing/console-command-event-listener')]
1922
public function start(ConsoleCommandEvent $event): void
2023
{
2124
$this->stopWatches[] = TimingUtility::stopWatch('console.command', (string)$event->getCommand()?->getName());
2225
}
2326

27+
#[AsEventListener('kanti/server-timing/console-terminate-event-listener')]
2428
public function stop(ConsoleTerminateEvent $event): void
2529
{
2630
$stopWatch = array_pop($this->stopWatches);
@@ -32,5 +36,14 @@ public function stop(ConsoleTerminateEvent $event): void
3236
if (!$this->stopWatches) {
3337
TimingUtility::getInstance()->shutdown(ScriptResult::fromCli($event->getExitCode()));
3438
}
39+
40+
$event->getOutput()->writeln(
41+
sprintf(
42+
'<info>server_timing:</info> Command "%s" took %.4fs',
43+
(string)$event->getCommand()?->getName(),
44+
$stopWatch->getDuration(),
45+
),
46+
OutputInterface::VERBOSITY_VERBOSE,
47+
);
3548
}
3649
}

Classes/EventListener/FileProcessingEventListener.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
use Kanti\ServerTiming\Dto\StopWatch;
88
use Kanti\ServerTiming\Utility\TimingUtility;
9+
use TYPO3\CMS\Core\Attribute\AsEventListener;
910
use TYPO3\CMS\Core\Resource\Event\AfterFileProcessingEvent;
1011
use TYPO3\CMS\Core\Resource\Event\BeforeFileProcessingEvent;
1112

1213
final class FileProcessingEventListener
1314
{
1415
public StopWatch|null $stopWatch = null;
1516

17+
#[AsEventListener('kanti/server-timing/file-processing')]
1618
public function before(BeforeFileProcessingEvent $event): void
1719
{
1820
if (!$event->getProcessedFile()->isProcessed()) {
@@ -21,6 +23,7 @@ public function before(BeforeFileProcessingEvent $event): void
2123
}
2224
}
2325

26+
#[AsEventListener('kanti/server-timing/file-processing')]
2427
public function after(AfterFileProcessingEvent $event): void
2528
{
2629
$this->stopWatch?->stopIfNot();

Classes/EventListener/MailEventListener.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,33 @@
44

55
namespace Kanti\ServerTiming\EventListener;
66

7+
use Symfony\Component\Mime\Address;
78
use Kanti\ServerTiming\Dto\StopWatch;
89
use Kanti\ServerTiming\Utility\TimingUtility;
910
use Symfony\Component\Mime\Email;
11+
use TYPO3\CMS\Core\Attribute\AsEventListener;
1012
use TYPO3\CMS\Core\Mail\Event\AfterMailerSentMessageEvent;
1113
use TYPO3\CMS\Core\Mail\Event\BeforeMailerSentMessageEvent;
1214

1315
final class MailEventListener
1416
{
1517
public ?StopWatch $stopWatch = null;
1618

19+
#[AsEventListener('kanti/server-timing/mail-event-listener')]
1720
public function start(BeforeMailerSentMessageEvent $event): void
1821
{
1922
$info = '';
2023
$message = $event->getMessage();
2124
if ($message instanceof Email) {
22-
$emails = implode(', ', array_map(static fn($address): string => $address->getAddress(), $message->getTo()));
25+
$emails = implode(', ', array_map(static fn(Address $address): string => $address->getAddress(), $message->getTo()));
2326
$info = $message->getSubject() . ' -> ' . $emails;
2427
}
2528

2629
$this->stopWatch?->stopIfNot();
2730
$this->stopWatch = TimingUtility::stopWatch('mail', $info);
2831
}
2932

33+
#[AsEventListener('kanti/server-timing/mail-event-listener')]
3034
public function stop(AfterMailerSentMessageEvent $event): void
3135
{
3236
$this->stopWatch?->stopIfNot();

Classes/Middleware/AdminpanelSqlLoggingMiddleware.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

Classes/Middleware/WrapMiddleware.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,9 @@ public function handle(ServerRequestInterface $request): ResponseInterface
3535
self::$middlewareIn?->stopIfNot();
3636
self::$middlewareIn = TimingUtility::stopWatch($this->isKernel ? 'requestHandler' : 'middleware.in', $this->info);
3737

38-
if ($this->isKernel) {
39-
$request->getAttribute('middleware.in.total')?->stop();
40-
}
4138

4239
$response = $this->requestHandler->handle($request);
4340

44-
if ($this->isKernel) {
45-
TimingUtility::start('middleware.out.total');
46-
}
4741

4842
// if it was the requestHandler:
4943
self::$middlewareIn?->stopIfNot();

0 commit comments

Comments
 (0)