Project

General

Profile

Typo3 V10 > V11 » History » Version 2

Enis Nuredini, 09.04.2023 22:36

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