Project

General

Profile

Typo3 V10 > V11 » History » Version 15

Enis Nuredini, 07.06.2023 09:15

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 10 Enis Nuredini
h3. 1. Extensions Upgrades
6 3 Enis Nuredini
7 4 Enis Nuredini
|_.Extension|_.Version|
8 2 Enis Nuredini
|  LDAP|  V3.7.1|
9
10 15 Enis Nuredini
h2. Punkt 2, 3 und 4 werden nicht mehr benötigt wenn aktuellste QFQ Dev Version verwendet wird. (Master Release noch in Arbeit).
11 2 Enis Nuredini
12 10 Enis Nuredini
h3. 2. File ext_localconf.php
13 1 Enis Nuredini
14
The configurePlugin block needs to be changed to following:
15
<pre>
16
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
17
    'IMATHUZH.qfq',
18
    'Qfq',
19
    [\IMATHUZH\Qfq\Controller\QfqController::class => 'show'],
20
    [\IMATHUZH\Qfq\Controller\QfqController::class => 'show'], // put here as well, if controller output must not be cached
21
    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
22
);
23
</pre>
24
25
26 10 Enis Nuredini
h3. 3. QFQ Class QfqController.php
27 1 Enis Nuredini
28
Two new needed Classes needs to be linked:
29
<pre>
30
use Psr\Http\Message\ResponseInterface;
31
use TYPO3\CMS\Core\Http\HtmlResponse;
32
</pre>
33
34
Changes for the showAction() function:
35
<pre>
36
    public function showAction(): ResponseInterface {
37
38
        $html = '';
39
        $origErrorReporting = '';
40
        $flagOk = false;
41
42
        try {
43
            $contentObject = $this->configurationManager->getContentObject();
44
45
            // By T3 default 'E_NOTICE' is unset. E.g. 'Undefined Index' will throw an exception.
46
            // QFQ like to see those 'E_NOTICE'
47
            $origErrorReporting = error_reporting();
48
            error_reporting($origErrorReporting | E_NOTICE);
49
50
            $qfq = new QuickFormQuery($contentObject->data);
51
            $html = $qfq->process();
52
            $flagOk = true;
53
54
        } catch (\UserFormException $e) {
55
            $html = $e->formatMessage();
56
57
        } catch (\UserReportException $e) {
58
            $html = $e->formatMessage();
59
60
        } catch (\CodeException $e) {
61
            $html = $e->formatMessage();
62
63
        } catch (\DbException $e) {
64
            $html = $e->formatMessage();
65
66
        } catch (\ShellException $e) {
67
            $html = $e->formatMessage();
68
69
        } catch (\DownloadException $e) {
70
            $html = $e->formatMessage();
71
72
        } catch (\Exception $e) {
73
            $ee = new \UserReportException(json_encode([
74
                ERROR_MESSAGE_TO_USER => "Generic Exception: " . $e->getMessage(),
75
                ERROR_MESSAGE_TO_DEVELOPER => $e->getTraceAsString()]), E_ERROR);
76
            $html = $ee->formatMessage();
77
        } catch (\Throwable $e) {
78
            $ee = new \UserReportException(json_encode([
79
                ERROR_MESSAGE_TO_USER => "Generic Error: " . $e->getMessage(),
80
                ERROR_MESSAGE_TO_DEVELOPER => $e->getTraceAsString()]), E_ERROR);
81
            $html = $ee->formatMessage();
82
        }
83
84
        if (isset($e) && $e->getCode() == ERROR_QUIT_QFQ_REGULAR) {
85
            $flagOk = true;
86
        }
87
88
        if (!$flagOk) {
89
            $html = "<div class='alert alert-warning'>$html</div>";
90
        }
91
92
        // Restore has to be outside of try/catch - E_NOTICE needs to unset for further T3 handling after an QFQ Exception.
93
        error_reporting($origErrorReporting);
94
95
        $this->view->assign('qfqOutput', $html);
96
        $content = $this->view->render();
97
        
98
        return new HtmlResponse($content);
99
    }
100
</pre>
101
102
We see that the new Typo3 versions are waiting for returned HtmlResponse Objects.
103 5 Enis Nuredini
104 10 Enis Nuredini
h3. 4. Services.yaml (necessary file)
105 5 Enis Nuredini
106 8 Enis Nuredini
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 to set in /typo3conf/ext/qfq/Configuration
107 7 Enis Nuredini
108 5 Enis Nuredini
Content of the file:
109
<pre>
110
services:
111
  IMATHUZH\Qfq\Controller\QfqController:
112
    autowire: true
113
    autoconfigure: true
114 1 Enis Nuredini
    public: false
115
</pre>
116
117
Cache should be flushed after creating Services.yaml: Admin Tools > Maintenance > Flush TYPO3 and PHP Cache (Flush cache).
118 10 Enis Nuredini
119
h3. 5. Felogin with Fluid Template
120
121
The actually used login template from uzh_cd extension doesnt work for Typo3 V11. Newly a fluid template is required and login/logout are separately defined. Current solution to get it work is to write the templates named with Login.html and Logout.html. These two files needs to overwrite the existing ones under following directory: typo3/sysext/felogin/Resources/Private/Templates/Login
122
123
The better solution would be using own path for the templates, which didnt work to me, but maybe it works for someone:
124
125
<pre>
126
plugin.tx_felogin {
127
    view {
128
        templateRootPaths {
129
            100 = EXT:uzh_cd_template/Resources/Private/Templates
130
        }
131
    }
132
}
133
</pre> 
134
135
Template files with content for the default fluid versions of the uzh templates are uploaded here and should match the old design (little bit specified for the geolean tool, do your own changes). Its not dynamically customizable over Typo3 Backend like the old template.
136
137
Examples of currently not working typoScript configurations for felogin:
138
* Linking own template
139
* Using own message wraps commands like this one: plugin.tx_felogin_pi1.errorMessage_stdWrap.wrap =
140 12 Enis Nuredini
141
h3. 6. Custom CSS Files
142
143 13 Enis Nuredini
The given token 'cd.stylesheet =' from uzh_cd extension would not work correctly anymore with relative paths in newer Typo3 versions. The reason are used pageSlugs, which changes the path for the given custom CSS in every visited page. 
144
145
Here are two example results with following used TypoScript config: cd.stylesheet = fileadmin/templates/custom.css:
146 12 Enis Nuredini
147
Working version:
148
<pre>
149
Typo3 V8 with index.php and example page 
150
www.domain.com/index.php?id=10 -> www.domain.com/fileadmin/templates/custom.css
151
</pre>
152
153
Not working version:
154
<pre>
155
Typo3 V11 with pageSlug and example page
156 14 Enis Nuredini
www.domain.com/subpage -> www.domain.com/subpage/fileadmin/templates/custom.css
157 12 Enis Nuredini
</pre>
158
159
Solution: Use absolute paths for custom files in cd.stylesheet option.