[!!!][TASK] Remove utf8 conversion in EXT:recycler 73/45373/2
authorBenni Mack <benni@typo3.org>
Sat, 19 Dec 2015 20:35:53 +0000 (21:35 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Mon, 21 Dec 2015 18:27:34 +0000 (19:27 +0100)
The recycler module handles conversions to UTF8 and to
other charsets, although the backend is solely UTF-8 since TYPO3 4.5. The logic and the according functions
have been removed as they have no effect and only
add complexity to code and slows down processing.

Resolves: #72334
Releases: master
Change-Id: Ifdae4a494e84dec1a7c42e96f36e48ecbf840ff3
Reviewed-on: https://review.typo3.org/45373
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/core/Documentation/Changelog/master/Breaking-72334-RemoveUtf8ConversionInEXTrecycler.rst [new file with mode: 0644]
typo3/sysext/recycler/Classes/Controller/DeletedRecordsController.php
typo3/sysext/recycler/Classes/Domain/Model/Tables.php
typo3/sysext/recycler/Classes/Utility/RecyclerUtility.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-72334-RemoveUtf8ConversionInEXTrecycler.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-72334-RemoveUtf8ConversionInEXTrecycler.rst
new file mode 100644 (file)
index 0000000..f42cd89
--- /dev/null
@@ -0,0 +1,36 @@
+=========================================================
+Breaking: #72334 - Remove utf8 conversion in EXT:recycler
+=========================================================
+
+Description
+===========
+
+The recycler module previously handled conversions of labels to and from UTF-8 in order to send proper UTF-8
+encoded data via JavaScript. The TYPO3 backend is running with UTF-8 since TYPO3 4.5.
+
+The logic and the according functions have been removed as they are not needed anymore.
+
+
+Impact
+======
+
+The following methods have been removed:
+
+
+.. code-block:: php
+
+       RecyclerUtility::getUtf8String()
+       RecyclerUtility::isNotUtf8Charset()
+       RecyclerUtility::getCurrentCharset()
+
+
+Affected Installations
+======================
+
+Any TYPO3 instance directly accessing any of the mentioned RecyclerUtility methods above via a custom extension.
+
+
+Migration
+=========
+
+Remove the usages to these methods, and use the strings directly.
\ No newline at end of file
index 3da46f6..a19a041 100644 (file)
@@ -58,7 +58,6 @@ class DeletedRecordsController
 
         if (is_array($deletedRowsArray)) {
             $lang = $this->getLanguageService();
-            $backendUser = $this->getBackendUser();
             $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
 
             foreach ($deletedRowsArray as $table => $rows) {
@@ -70,14 +69,14 @@ class DeletedRecordsController
                         'uid' => $row['uid'],
                         'pid' => $row['pid'],
                         'icon' => $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render(),
-                        'pageTitle' => RecyclerUtility::getUtf8String($pageTitle),
+                        'pageTitle' => $pageTitle,
                         'table' => $table,
                         'crdate' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]),
                         'tstamp' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]),
                         'owner' => htmlspecialchars($backendUser['username']),
                         'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']],
-                        'tableTitle' => RecyclerUtility::getUtf8String($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])),
-                        'title' => htmlspecialchars(RecyclerUtility::getUtf8String(BackendUtility::getRecordTitle($table, $row))),
+                        'tableTitle' => $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']),
+                        'title' => htmlspecialchars(BackendUtility::getRecordTitle($table, $row)),
                         'path' => RecyclerUtility::getRecordPath($row['pid'])
                     );
                 }
@@ -121,16 +120,6 @@ class DeletedRecordsController
     }
 
     /**
-     * Returns the current BE user.
-     *
-     * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
-     */
-    protected function getBackendUser()
-    {
-        return $GLOBALS['BE_USER'];
-    }
-
-    /**
      * Create and returns an instance of the CacheManager
      *
      * @return \TYPO3\CMS\Core\Cache\CacheManager
index b4c7b74..cba3abf 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Recycler\Domain\Model;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Recycler\Utility\RecyclerUtility;
 
 /**
@@ -39,8 +40,8 @@ class Tables
                 // Determine whether the table has deleted records:
                 $deletedCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', $tableName, $deletedField . '<>0');
                 if ($deletedCount) {
-                    /* @var $deletedDataObject \TYPO3\CMS\Recycler\Domain\Model\DeletedRecords */
-                    $deletedDataObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Recycler\Domain\Model\DeletedRecords::class);
+                    /* @var $deletedDataObject DeletedRecords */
+                    $deletedDataObject = GeneralUtility::makeInstance(DeletedRecords::class);
                     $deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows();
                     if (isset($deletedData[$tableName])) {
                         if ($deletedRecordsInTable = count($deletedData[$tableName])) {
@@ -48,7 +49,7 @@ class Tables
                             $tables[] = array(
                                 $tableName,
                                 $deletedRecordsInTable,
-                                RecyclerUtility::getUtf8String($lang->sL($GLOBALS['TCA'][$tableName]['ctrl']['title']))
+                                $lang->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'])
                             );
                         }
                     }
index f8e6e94..5c1ebd3 100644 (file)
@@ -149,41 +149,6 @@ class RecyclerUtility
     }
 
     /**
-     * Gets the current backend charset.
-     *
-     * @return string The current backend charset
-     */
-    public static function getCurrentCharset()
-    {
-        $lang = static::getLanguageService();
-        return $lang->csConvObj->parse_charset($lang->charSet);
-    }
-
-    /**
-     * Determines whether the current charset is not UTF-8
-     *
-     * @return bool Whether the current charset is not UTF-8
-     */
-    public static function isNotUtf8Charset()
-    {
-        return self::getCurrentCharset() !== 'utf-8';
-    }
-
-    /**
-     * Gets an UTF-8 encoded string (only if the current charset is not UTF-8!).
-     *
-     * @param string $string String to be converted to UTF-8 if required
-     * @return string UTF-8 encoded string
-     */
-    public static function getUtf8String($string)
-    {
-        if (self::isNotUtf8Charset()) {
-            $string = static::getLanguageService()->csConvObj->utf8_encode($string, self::getCurrentCharset());
-        }
-        return $string;
-    }
-
-    /**
      * Returns an instance of DatabaseConnection
      *
      * @return \TYPO3\CMS\Core\Database\DatabaseConnection