Project

General

Profile

Typo3 V10 > V11 » History » Revision 6

Revision 5 (Enis Nuredini, 09.04.2023 22:44) → Revision 6/22 (Enis Nuredini, 09.04.2023 22:45)

h1. Migration Typo3 v10 > v11 

 Some changes in php are needed to get QFQ work in v11. 

 h3. Extensions Upgrades 

 |_.Extension|_.Version| 
 |    LDAP|    V3.7.1| 


 h3. File ext_localconf.php 

 The configurePlugin block needs to be changed to following: 
 <pre> 
 \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( 
     'IMATHUZH.qfq', 
     'Qfq', 
     [\IMATHUZH\Qfq\Controller\QfqController::class => 'show'], 
     [\IMATHUZH\Qfq\Controller\QfqController::class => 'show'], // put here as well, if controller output must not be cached 
     \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT 
 ); 
 </pre> 


 h3. QFQ Class QfqController.php 

 Two new needed Classes needs to be linked: 
 <pre> 
 use Psr\Http\Message\ResponseInterface; 
 use TYPO3\CMS\Core\Http\HtmlResponse; 
 </pre> 

 Changes for the showAction() function: 
 <pre> 
     public function showAction(): ResponseInterface { 

         $html = ''; 
         $origErrorReporting = ''; 
         $flagOk = false; 

         try { 
             $contentObject = $this->configurationManager->getContentObject(); 

             // By T3 default 'E_NOTICE' is unset. E.g. 'Undefined Index' will throw an exception. 
             // QFQ like to see those 'E_NOTICE' 
             $origErrorReporting = error_reporting(); 
             error_reporting($origErrorReporting | E_NOTICE); 

             $qfq = new QuickFormQuery($contentObject->data); 
             $html = $qfq->process(); 
             $flagOk = true; 

         } catch (\UserFormException $e) { 
             $html = $e->formatMessage(); 

         } catch (\UserReportException $e) { 
             $html = $e->formatMessage(); 

         } catch (\CodeException $e) { 
             $html = $e->formatMessage(); 

         } catch (\DbException $e) { 
             $html = $e->formatMessage(); 

         } catch (\ShellException $e) { 
             $html = $e->formatMessage(); 

         } catch (\DownloadException $e) { 
             $html = $e->formatMessage(); 

         } catch (\Exception $e) { 
             $ee = new \UserReportException(json_encode([ 
                 ERROR_MESSAGE_TO_USER => "Generic Exception: " . $e->getMessage(), 
                 ERROR_MESSAGE_TO_DEVELOPER => $e->getTraceAsString()]), E_ERROR); 
             $html = $ee->formatMessage(); 
         } catch (\Throwable $e) { 
             $ee = new \UserReportException(json_encode([ 
                 ERROR_MESSAGE_TO_USER => "Generic Error: " . $e->getMessage(), 
                 ERROR_MESSAGE_TO_DEVELOPER => $e->getTraceAsString()]), E_ERROR); 
             $html = $ee->formatMessage(); 
         } 

         if (isset($e) && $e->getCode() == ERROR_QUIT_QFQ_REGULAR) { 
             $flagOk = true; 
         } 

         if (!$flagOk) { 
             $html = "<div class='alert alert-warning'>$html</div>"; 
         } 

         // Restore has to be outside of try/catch - E_NOTICE needs to unset for further T3 handling after an QFQ Exception. 
         error_reporting($origErrorReporting); 

         $this->view->assign('qfqOutput', $html); 
         $content = $this->view->render(); 
        
         return new HtmlResponse($content); 
     } 
 </pre> 

 We see that the new Typo3 versions are waiting for returned HtmlResponse Objects. 

 

 h3. Services.yaml (necessary file) 

 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 
 Content of the file: 
 <pre> 
 services: 
   IMATHUZH\Qfq\Controller\QfqController: 
     autowire: true 
     autoconfigure: true 
     public: false 
 </pre>