Project

General

Profile

Typo3 V10 > V11 » History » Version 16

Enis Nuredini, 07.06.2023 09:16

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