[TASK] Deprecate GeneralUtility::csvValues 63/52163/2
authorFrank Naegler <frank.naegler@typo3.org>
Sat, 25 Mar 2017 23:09:17 +0000 (00:09 +0100)
committerBenni Mack <benni@typo3.org>
Sat, 25 Mar 2017 23:38:24 +0000 (00:38 +0100)
Resolves: #80451
Releases: master
Change-Id: I7ba0a97b3ca4bfb98b1f5072a830d10b66e640fd
Reviewed-on: https://review.typo3.org/52163
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Database/QueryView.php
typo3/sysext/core/Classes/Utility/CsvUtility.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-80451-DeprecateGeneralUtilitycsvValues.rst [new file with mode: 0644]
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index dac343d..746ac85 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageRendererResolver;
+use TYPO3\CMS\Core\Utility\CsvUtility;
 use TYPO3\CMS\Core\Utility\DebugUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -575,7 +576,7 @@ class QueryView
                 $valueArray[$key] = $this->getProcessedValueExtra($table, $key, $val, $conf, ';');
             }
         }
-        return GeneralUtility::csvValues($valueArray, $delim, $quote);
+        return CsvUtility::csvValues($valueArray, $delim, $quote);
     }
 
     /**
index ee15570..daf8e7f 100644 (file)
@@ -67,4 +67,21 @@ class CsvUtility
 
         return $multiArray;
     }
+
+    /**
+     * Takes a row and returns a CSV string of the values with $delim (default is ,) and $quote (default is ") as separator chars.
+     *
+     * @param array $row Input array of values
+     * @param string $delim Delimited, default is comma
+     * @param string $quote Quote-character to wrap around the values.
+     * @return string A single line of CSV
+     */
+    public static function csvValues(array $row, $delim = ',', $quote = '"')
+    {
+        $out = [];
+        foreach ($row as $value) {
+            $out[] = str_replace($quote, $quote . $quote, $value);
+        }
+        return $quote . implode($quote . $delim . $quote, $out) . $quote;
+    }
 }
index f7591a9..d3828c1 100644 (file)
@@ -1391,15 +1391,12 @@ class GeneralUtility
      * @param string $delim Delimited, default is comma
      * @param string $quote Quote-character to wrap around the values.
      * @return string A single line of CSV
+     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9.
      */
     public static function csvValues(array $row, $delim = ',', $quote = '"')
     {
-        $out = [];
-        foreach ($row as $value) {
-            $out[] = str_replace($quote, $quote . $quote, $value);
-        }
-        $str = $quote . implode(($quote . $delim . $quote), $out) . $quote;
-        return $str;
+        self::logDeprecatedFunction();
+        return CsvUtility::csvValues($row, $delim, $quote);
     }
 
     /**
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80451-DeprecateGeneralUtilitycsvValues.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80451-DeprecateGeneralUtilitycsvValues.rst
new file mode 100644 (file)
index 0000000..103f1d3
--- /dev/null
@@ -0,0 +1,27 @@
+.. include:: ../../Includes.txt
+
+=========================================================
+Deprecation: #80451 - Deprecate GeneralUtility::csvValues
+=========================================================
+
+See :issue:`80451`
+
+Description
+===========
+
+The method :php:`GeneralUtility::csvValues()` has been marked as deprecated.
+
+
+Impact
+======
+
+Calling the deprecated methods will trigger a deprecation log entry.
+
+
+Migration
+=========
+
+Use the new method :php:`CsvUtility::csvValues()`
+
+
+.. index:: Backend, PHP-API
index ebd219b..c249534 100644 (file)
@@ -28,6 +28,7 @@ use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
+use TYPO3\CMS\Core\Utility\CsvUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -2219,7 +2220,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList
      */
     public function setCsvRow($csvRow)
     {
-        $this->csvLines[] = GeneralUtility::csvValues($csvRow);
+        $this->csvLines[] = CsvUtility::csvValues($csvRow);
     }
 
     /**