Project

General

Profile

Typo3 V10 > V11 » History » Version 5

Enis Nuredini, 09.04.2023 22:44

1 1 Enis Nuredini
h1. Migration Typo3 v10 > v11
2
3
Some changes in php are needed to get QFQ work in v11.
4
5 2 Enis Nuredini
h3. Extensions Upgrades
6 3 Enis Nuredini
7 4 Enis Nuredini
|_.Extension|_.Version|
8 2 Enis Nuredini
|  LDAP|  V3.7.1|
9
10
11 1 Enis Nuredini
h3. File ext_localconf.php
12
13
The configurePlugin block needs to be changed to following:
14
<pre>
15
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
16
    'IMATHUZH.qfq',
17
    'Qfq',
18
    [\IMATHUZH\Qfq\Controller\QfqController::class => 'show'],
19
    [\IMATHUZH\Qfq\Controller\QfqController::class => 'show'], // put here as well, if controller output must not be cached
20
    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
21
);
22
</pre>
23
24
25
h3. QFQ Class QfqController.php
26
27
Two new needed Classes needs to be linked:
28
<pre>
29
use Psr\Http\Message\ResponseInterface;
30
use TYPO3\CMS\Core\Http\HtmlResponse;
31
</pre>
32
33
Changes for the showAction() function:
34
<pre>
35
    public function showAction(): ResponseInterface {
36
37
        $html = '';
38
        $origErrorReporting = '';
39
        $flagOk = false;
40
41
        try {
42
            $contentObject = $this->configurationManager->getContentObject();
43
44
            // By T3 default 'E_NOTICE' is unset. E.g. 'Undefined Index' will throw an exception.
45
            // QFQ like to see those 'E_NOTICE'
46
            $origErrorReporting = error_reporting();
47
            error_reporting($origErrorReporting | E_NOTICE);
48
49
            $qfq = new QuickFormQuery($contentObject->data);
50
            $html = $qfq->process();
51
            $flagOk = true;
52
53
        } catch (\UserFormException $e) {
54
            $html = $e->formatMessage();
55
56
        } catch (\UserReportException $e) {
57
            $html = $e->formatMessage();
58
59
        } catch (\CodeException $e) {
60
            $html = $e->formatMessage();
61
62
        } catch (\DbException $e) {
63
            $html = $e->formatMessage();
64
65
        } catch (\ShellException $e) {
66
            $html = $e->formatMessage();
67
68
        } catch (\DownloadException $e) {
69
            $html = $e->formatMessage();
70
71
        } catch (\Exception $e) {
72
            $ee = new \UserReportException(json_encode([
73
                ERROR_MESSAGE_TO_USER => "Generic Exception: " . $e->getMessage(),
74
                ERROR_MESSAGE_TO_DEVELOPER => $e->getTraceAsString()]), E_ERROR);
75
            $html = $ee->formatMessage();
76
        } catch (\Throwable $e) {
77
            $ee = new \UserReportException(json_encode([
78
                ERROR_MESSAGE_TO_USER => "Generic Error: " . $e->getMessage(),
79
                ERROR_MESSAGE_TO_DEVELOPER => $e->getTraceAsString()]), E_ERROR);
80
            $html = $ee->formatMessage();
81
        }
82
83
        if (isset($e) && $e->getCode() == ERROR_QUIT_QFQ_REGULAR) {
84
            $flagOk = true;
85
        }
86
87
        if (!$flagOk) {
88
            $html = "<div class='alert alert-warning'>$html</div>";
89
        }
90
91
        // Restore has to be outside of try/catch - E_NOTICE needs to unset for further T3 handling after an QFQ Exception.
92
        error_reporting($origErrorReporting);
93
94
        $this->view->assign('qfqOutput', $html);
95
        $content = $this->view->render();
96
        
97
        return new HtmlResponse($content);
98
    }
99
</pre>
100
101
We see that the new Typo3 versions are waiting for returned HtmlResponse Objects.
102 5 Enis Nuredini
103
h3. Services.yaml (necessary file)
104
105
For correct qfqController handling and preventing use of ObjectManager (which is deprecated in T3 V12) a services.yaml file is needed. Location for this file is set in /typo3conf/ext/qfq/Configuration
106
Content of the file:
107
<pre>
108
services:
109
  IMATHUZH\Qfq\Controller\QfqController:
110
    autowire: true
111
    autoconfigure: true
112
    public: false
113
</pre>