Typo3 V10 > V11 » History » Version 13
Enis Nuredini, 13.04.2023 10:30
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 | |||
11 | 10 | Enis Nuredini | h3. 2. File ext_localconf.php |
12 | 1 | Enis Nuredini | |
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 | 10 | Enis Nuredini | h3. 3. QFQ Class QfqController.php |
26 | 1 | Enis Nuredini | |
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 | 10 | Enis Nuredini | h3. 4. Services.yaml (necessary file) |
104 | 5 | Enis Nuredini | |
105 | 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 |
106 | 7 | Enis Nuredini | |
107 | 5 | Enis Nuredini | Content of the file: |
108 | <pre> |
||
109 | services: |
||
110 | IMATHUZH\Qfq\Controller\QfqController: |
||
111 | autowire: true |
||
112 | autoconfigure: true |
||
113 | 1 | Enis Nuredini | public: false |
114 | </pre> |
||
115 | |||
116 | Cache should be flushed after creating Services.yaml: Admin Tools > Maintenance > Flush TYPO3 and PHP Cache (Flush cache). |
||
117 | 10 | Enis Nuredini | |
118 | h3. 5. Felogin with Fluid Template |
||
119 | |||
120 | 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 |
||
121 | |||
122 | The better solution would be using own path for the templates, which didnt work to me, but maybe it works for someone: |
||
123 | |||
124 | <pre> |
||
125 | plugin.tx_felogin { |
||
126 | view { |
||
127 | templateRootPaths { |
||
128 | 100 = EXT:uzh_cd_template/Resources/Private/Templates |
||
129 | } |
||
130 | } |
||
131 | } |
||
132 | </pre> |
||
133 | |||
134 | 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. |
||
135 | |||
136 | Examples of currently not working typoScript configurations for felogin: |
||
137 | * Linking own template |
||
138 | * Using own message wraps commands like this one: plugin.tx_felogin_pi1.errorMessage_stdWrap.wrap = |
||
139 | 12 | Enis Nuredini | |
140 | h3. 6. Custom CSS Files |
||
141 | |||
142 | 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. |
143 | |||
144 | Here are two example results with following used TypoScript config: cd.stylesheet = fileadmin/templates/custom.css: |
||
145 | 12 | Enis Nuredini | |
146 | Working version: |
||
147 | <pre> |
||
148 | Typo3 V8 with index.php and example page |
||
149 | www.domain.com/index.php?id=10 -> www.domain.com/fileadmin/templates/custom.css |
||
150 | </pre> |
||
151 | |||
152 | Not working version: |
||
153 | <pre> |
||
154 | Typo3 V11 with pageSlug and example page |
||
155 | www.domain.com/subpage -> www.domain.com/ *subpage* /fileadmin/templates/custom.css |
||
156 | </pre> |
||
157 | |||
158 | Solution: Use absolute paths for custom files in cd.stylesheet option. |