[!!!][TASK] Move xhtml_cleaning check to compatibility6 27/36527/6
authorJan Helke <typo3@helke.de>
Sat, 31 Jan 2015 16:24:32 +0000 (17:24 +0100)
committerBenjamin Mack <benni@typo3.org>
Sat, 31 Jan 2015 17:16:11 +0000 (18:16 +0100)
XHTML cleaning is not neccessary anymore, after modern technology
bases completely on HTML5. Therefore the according functionality
has been moved to the legacy extension "compatibility6".

Resolves: #62855
Releases: master
Change-Id: I4f4b7cfd2388d516951b0f37b399b0359b44c487
Reviewed-on: http://review.typo3.org/36527
Reviewed-by: Göran Bodenschatz <coding@46halbe.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/compatibility6/Classes/Hooks/TypoScriptFrontendController/ContentPostProcHook.php [new file with mode: 0644]
typo3/sysext/compatibility6/ext_localconf.php
typo3/sysext/core/Classes/Html/HtmlParser.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-62855-XHTMLCleaningMovedToLegacyExtension.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Page/PageGenerator.php

diff --git a/typo3/sysext/compatibility6/Classes/Hooks/TypoScriptFrontendController/ContentPostProcHook.php b/typo3/sysext/compatibility6/Classes/Hooks/TypoScriptFrontendController/ContentPostProcHook.php
new file mode 100644 (file)
index 0000000..1690932
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+namespace TYPO3\CMS\Compatibility6\Hooks\TypoScriptFrontendController;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Class that hooks into TypoScriptFrontendController to do XHTML cleaning
+ */
+class ContentPostProcHook {
+
+       /**
+        * @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
+        */
+       protected $pObj;
+
+       /**
+        * XHTML-clean the code, if flag config.xhtml_cleaning is set
+        * to "all"
+        *
+        * @param $parameters array
+        * @param $parentObject \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
+        */
+       public function contentPostProcAll(&$parameters, $parentObject) {
+               $this->pObj = $parentObject;
+               // XHTML-clean the code, if flag set
+               if ($this->doXHTML_cleaning() == 'all') {
+                       $GLOBALS['TT']->push('XHTML clean, all', '');
+                       $XHTML_clean = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\HtmlParser::class);
+                       $this->pObj->content = $XHTML_clean->XHTML_clean($this->pObj->content);
+                       $GLOBALS['TT']->pull();
+               }
+       }
+
+       /**
+        * XHTML-clean the code, if flag config.xhtml_cleaning is set
+        * to "cached"
+        *
+        * @param $parameters array
+        * @param $parentObject \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
+        */
+       public function contentPostProcCached(&$parameters, $parentObject) {
+               $this->pObj = $parentObject;
+               // XHTML-clean the code, if flag set
+               if ($this->doXHTML_cleaning() == 'cached') {
+                       $GLOBALS['TT']->push('XHTML clean, cached', '');
+                       $XHTML_clean = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\HtmlParser::class);
+                       $this->pObj->content = $XHTML_clean->XHTML_clean($this->pObj->content);
+                       $GLOBALS['TT']->pull();
+               }
+       }
+
+       /**
+        * XHTML-clean the code, if flag config.xhtml_cleaning is set
+        * to "output"
+        *
+        * @param $parameters array
+        * @param $parentObject \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
+        */
+       public function contentPostProcOutput(&$parameters, $parentObject) {
+               $this->pObj = $parentObject;
+               // XHTML-clean the code, if flag set
+               if ($this->doXHTML_cleaning() == 'output') {
+                       $GLOBALS['TT']->push('XHTML clean, output', '');
+                       $XHTML_clean = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\HtmlParser::class);
+                       $this->pObj->content = $XHTML_clean->XHTML_clean($this->pObj->content);
+                       $GLOBALS['TT']->pull();
+               }
+       }
+
+       /**
+        * Returns the mode of XHTML cleaning
+        *
+        * @return string Keyword: "all", "cached" or "output"
+        */
+       protected function doXHTML_cleaning() {
+               if ($this->pObj->config['config']['xmlprologue'] == 'none') {
+                       return 'none';
+               }
+               return $this->pObj->config['config']['xhtml_cleaning'];
+       }
+}
index 1cb6f84..e96960c 100644 (file)
@@ -14,6 +14,11 @@ if (TYPO3_MODE === 'FE') {
 
        // Register a hook for data submission
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission']['mailform'] = \TYPO3\CMS\Compatibility6\Controller\FormDataSubmissionController::class;
+
+       // Register hooks for xhtml_cleaning
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'][] = \TYPO3\CMS\Compatibility6\Hooks\TypoScriptFrontendController\ContentPostProcHook::class . '->contentPostProcAll';
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'][] = \TYPO3\CMS\Compatibility6\Hooks\TypoScriptFrontendController\ContentPostProcHook::class . '->contentPostProcCached';
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][] = \TYPO3\CMS\Compatibility6\Hooks\TypoScriptFrontendController\ContentPostProcHook::class . '->contentPostProcOutput';
 }
 
 // Add Default TS for CType "mailform" after default content rendering
index 7fab0b2..fd8dfdc 100644 (file)
@@ -1439,8 +1439,10 @@ class HtmlParser {
         * @param string $content Content to clean up
         * @return string Cleaned up content returned.
         * @access private
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
         */
        public function XHTML_clean($content) {
+               GeneralUtility::deprecationLog('The function \TYPO3\CMS\Core\Html\HtmlParser::XHTML_clean has been deprecated with TYPO3 CMS 7 and will be removed with CMS 8.');
                $content = $this->HTMLcleaner($content, array(), 1, 0, array('xhtml' => 1));
                return $content;
        }
@@ -1464,6 +1466,7 @@ class HtmlParser {
                // OK then, begin processing for XHTML output:
                // STILL VERY EXPERIMENTAL!!
                if ($conf['xhtml']) {
+                       GeneralUtility::deprecationLog('This section has been deprecated with TYPO3 CMS 7 and will be removed with CMS 8.');
                        // Endtags are just set lowercase right away
                        if ($endTag) {
                                $value = strtolower($value);
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-62855-XHTMLCleaningMovedToLegacyExtension.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-62855-XHTMLCleaningMovedToLegacyExtension.rst
new file mode 100644 (file)
index 0000000..9534b73
--- /dev/null
@@ -0,0 +1,38 @@
+==============================================================================
+Deprecation: #62855 - "XHTML cleaning" functionality moved to legacy extension
+==============================================================================
+
+Description
+===========
+
+XHTML cleaning is not necessary anymore, since modern technology bases completely on HTML5. Therefore the
+according functionality has been moved to the legacy extension "compatibility6".
+
+The following TypoScript option has been marked for deprecation:
+
+.. code-block:: ts
+
+       config.xhtml_cleaning
+
+The following PHP method has been marked for deprecation:
+
+.. code-block:: php
+
+       TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::doXHTML_cleaning()
+
+Impact
+======
+
+The content output of the TYPO3 frontend is not cleaned anymore unless the extension compatibility6 is installed.
+
+
+Affected installations
+======================
+
+Any installation having the TypoScript option ``config.xhtml_cleaning`` set will have different behaviour in the
+frontend rendering.
+
+Migration
+=========
+
+For TYPO3 CMS 7, installing the compatibility6 extension brings back the existing functionality.
index d329480..48c721a 100644 (file)
@@ -3235,13 +3235,6 @@ class TypoScriptFrontendController {
                if ($this->no_cacheBeforePageGen) {
                        $this->set_no_cache('no_cache has been set before the page was generated - safety check', TRUE);
                }
-               // XHTML-clean the code, if flag set
-               if ($this->doXHTML_cleaning() == 'all') {
-                       $GLOBALS['TT']->push('XHTML clean, all', '');
-                       $XHTML_clean = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\HtmlParser::class);
-                       $this->content = $XHTML_clean->XHTML_clean($this->content);
-                       $GLOBALS['TT']->pull();
-               }
                // Fix local anchors in links, if flag set
                if ($this->doLocalAnchorFix() == 'all') {
                        $GLOBALS['TT']->push('Local anchor fix, all', '');
@@ -3257,13 +3250,6 @@ class TypoScriptFrontendController {
                }
                // Processing if caching is enabled:
                if (!$this->no_cache) {
-                       // XHTML-clean the code, if flag set
-                       if ($this->doXHTML_cleaning() == 'cached') {
-                               $GLOBALS['TT']->push('XHTML clean, cached', '');
-                               $XHTML_clean = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\HtmlParser::class);
-                               $this->content = $XHTML_clean->XHTML_clean($this->content);
-                               $GLOBALS['TT']->pull();
-                       }
                        // Fix local anchors in links, if flag set
                        if ($this->doLocalAnchorFix() == 'cached') {
                                $GLOBALS['TT']->push('Local anchor fix, cached', '');
@@ -3476,8 +3462,11 @@ class TypoScriptFrontendController {
         * Returns the mode of XHTML cleaning
         *
         * @return string Keyword: "all", "cached" or "output
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
+        *
         */
        public function doXHTML_cleaning() {
+               GeneralUtility::deprecationLog('The TypoScript option "config.xhtml_cleaning" has been deprecated with TYPO3 CMS 7 and will be removed with CMS 8.');
                return $this->config['config']['xhtml_cleaning'];
        }
 
@@ -3559,13 +3548,6 @@ class TypoScriptFrontendController {
                if (!$this->isClientCachable) {
                        $this->contentStrReplace();
                }
-               // XHTML-clean the code, if flag set
-               if ($this->doXHTML_cleaning() == 'output') {
-                       $GLOBALS['TT']->push('XHTML clean, output', '');
-                       $XHTML_clean = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\HtmlParser::class);
-                       $this->content = $XHTML_clean->XHTML_clean($this->content);
-                       $GLOBALS['TT']->pull();
-               }
                // Fix local anchors in links, if flag set
                if ($this->doLocalAnchorFix() == 'output') {
                        $GLOBALS['TT']->push('Local anchor fix, output', '');
index d342a9c..d087a29 100644 (file)
@@ -291,7 +291,6 @@ class PageGenerator {
                switch ((string)$GLOBALS['TSFE']->config['config']['xmlprologue']) {
                        case 'none':
                                $xmlDocument = FALSE;
-                               $GLOBALS['TSFE']->config['config']['xhtml_cleaning'] = 'none';
                                break;
                        case 'xml_10':
                                $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';