Project

General

Profile

Actions

Typo3 V10 > V11 » History » Revision 4

« Previous | Revision 4/22 (diff) | Next »
Enis Nuredini, 09.04.2023 22:36


Migration Typo3 v10 > v11

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

Extensions Upgrades

Extension Version
LDAP V3.7.1

File ext_localconf.php

The configurePlugin block needs to be changed to following:

\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
);

QFQ Class QfqController.php

Two new needed Classes needs to be linked:

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Http\HtmlResponse;

Changes for the showAction() function:

    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);
    }

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

Updated by Enis Nuredini about 1 year ago · 4 revisions