From e6180569852a59b49a4baa6ac3b21b3bf88a44fc Mon Sep 17 00:00:00 2001
From: Frank Naegler <frank.naegler@typo3.org>
Date: Sun, 26 Mar 2017 00:09:17 +0100
Subject: [PATCH] [TASK] Deprecate GeneralUtility::csvValues

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>
---
 .../core/Classes/Database/QueryView.php       |  3 ++-
 .../core/Classes/Utility/CsvUtility.php       | 17 ++++++++++++
 .../core/Classes/Utility/GeneralUtility.php   |  9 +++----
 ...80451-DeprecateGeneralUtilitycsvValues.rst | 27 +++++++++++++++++++
 .../Classes/RecordList/DatabaseRecordList.php |  3 ++-
 5 files changed, 51 insertions(+), 8 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-80451-DeprecateGeneralUtilitycsvValues.rst

diff --git a/typo3/sysext/core/Classes/Database/QueryView.php b/typo3/sysext/core/Classes/Database/QueryView.php
index dac343db9261..746ac85abba0 100644
--- a/typo3/sysext/core/Classes/Database/QueryView.php
+++ b/typo3/sysext/core/Classes/Database/QueryView.php
@@ -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);
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Utility/CsvUtility.php b/typo3/sysext/core/Classes/Utility/CsvUtility.php
index ee1557010b7d..daf8e7f4b62f 100644
--- a/typo3/sysext/core/Classes/Utility/CsvUtility.php
+++ b/typo3/sysext/core/Classes/Utility/CsvUtility.php
@@ -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;
+    }
 }
diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
index f7591a9f1fbd..d3828c1a65b6 100644
--- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php
+++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
@@ -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
index 000000000000..103f1d32b357
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80451-DeprecateGeneralUtilitycsvValues.rst
@@ -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
diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
index ebd219b2c16d..c2495342f2e6 100644
--- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
+++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
@@ -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);
     }
 
     /**
-- 
GitLab