From e44470fb1cd3553dc029367dbf03ae1bb7be1d85 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Tue, 28 Nov 2017 18:08:07 +0100
Subject: [PATCH] [!!!][TASK] Remove custom userfunc of
 DataMapper->getPlainValue

DataMapper's hidden functionality of having a callback functionality
to modify a string before storing it in the database. This was used
for database abstraction with $TYPO3_DB ("fullQuoteStr"), which is now
obsolete for Extbase in general.

Thus, the code can be removed.

Resolves: #83241
Releases: master
Change-Id: Ic09c7572a19da570aebee969dd836371cddb5d43
Reviewed-on: https://review.typo3.org/54837
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Daniel Gorges <daniel.gorges@b13.de>
Tested-by: Daniel Gorges <daniel.gorges@b13.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
---
 ...nctionalityForDataMapper-getPlainValue.rst | 36 +++++++++++++++++++
 .../Persistence/Generic/Mapper/DataMapper.php | 27 +++-----------
 .../Generic/Storage/Typo3DbBackendTest.php    | 14 --------
 .../Php/MethodArgumentDroppedMatcher.php      |  6 ++++
 4 files changed, 46 insertions(+), 37 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Breaking-83241-ExtbaseRemovedCustomFunctionalityForDataMapper-getPlainValue.rst

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-83241-ExtbaseRemovedCustomFunctionalityForDataMapper-getPlainValue.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-83241-ExtbaseRemovedCustomFunctionalityForDataMapper-getPlainValue.rst
new file mode 100644
index 000000000000..ee6a36967464
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-83241-ExtbaseRemovedCustomFunctionalityForDataMapper-getPlainValue.rst
@@ -0,0 +1,36 @@
+.. include:: ../../Includes.txt
+
+======================================================================================
+Breaking: #83241 - Extbase: Removed custom functionality for DataMapper->getPlainValue
+======================================================================================
+
+See :issue:`83241`
+
+Description
+===========
+
+Extbase's DataMapper allowed for wrapping string values in custom user functions via custom parameters.
+This was primarily placed in DataMapper for allowing TYPO3's legacy DBAL / `$TYPO3_DB`.
+
+The functionality is now removed, as the Generic Backend is handled via Doctrine DBAL.
+
+
+Impact
+======
+
+Calling `DataMapper->getPlainValue()` with the third or fourth parameter set will have no effect anymore.
+
+
+Affected Installations
+======================
+
+In an VERY unlikely case of using a custom Persistence Backend within Extbase in an extension, some
+transformations will not work as expected anymore.
+
+
+Migration
+=========
+
+Use the transformations outside the DataMapper, if still necessary.
+
+.. index:: PHP-API, FullyScanned
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
index d26d3675cde5..b07bcc5a517b 100644
--- a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
+++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
@@ -681,13 +681,11 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface
      *
      * @param mixed $input The value that will be converted.
      * @param ColumnMap $columnMap Optional column map for retrieving the date storage format.
-     * @param callable $parseStringValueCallback Optional callback method that will be called for string values. Can be used to do database quotation.
-     * @param array $parseStringValueCallbackParameters Additional parameters that will be passed to the callabck as second parameter.
      * @throws \InvalidArgumentException
      * @throws UnexpectedTypeException
      * @return int|string
      */
-    public function getPlainValue($input, $columnMap = null, $parseStringValueCallback = null, array $parseStringValueCallbackParameters = [])
+    public function getPlainValue($input, $columnMap = null)
     {
         if ($input === null) {
             return 'NULL';
@@ -727,35 +725,18 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface
         } elseif (TypeHandlingUtility::isValidTypeForMultiValueComparison($input)) {
             $plainValueArray = [];
             foreach ($input as $inputElement) {
-                $plainValueArray[] = $this->getPlainValue($inputElement, $columnMap, $parseStringValueCallback, $parseStringValueCallbackParameters);
+                $plainValueArray[] = $this->getPlainValue($inputElement, $columnMap);
             }
             $parameter = implode(',', $plainValueArray);
         } elseif (is_object($input)) {
             if (TypeHandlingUtility::isCoreType($input)) {
-                $parameter = $this->getPlainStringValue($input, $parseStringValueCallback, $parseStringValueCallbackParameters);
+                $parameter = (string)$input;
             } else {
                 throw new UnexpectedTypeException('An object of class "' . get_class($input) . '" could not be converted to a plain value.', 1274799934);
             }
         } else {
-            $parameter = $this->getPlainStringValue($input, $parseStringValueCallback, $parseStringValueCallbackParameters);
+            $parameter = (string)$input;
         }
         return $parameter;
     }
-
-    /**
-     * If the given callback is set the value will be passed on the the callback function.
-     * The value will be converted to a string.
-     *
-     * @param string $value The string value that should be processed. Will be passed to the callback as first parameter.
-     * @param callable $callback The data passed to call_user_func().
-     * @param array $additionalParameters Optional additional parameters passed to the callback as second argument.
-     * @return string
-     */
-    protected function getPlainStringValue($value, $callback = null, array $additionalParameters = [])
-    {
-        if (is_callable($callback)) {
-            $value = call_user_func($callback, $value, $additionalParameters);
-        }
-        return (string)$value;
-    }
 }
diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
index 12e0986c36ad..cf3934a840b2 100644
--- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
+++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
@@ -20,7 +20,6 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
-use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
 
 /**
@@ -28,11 +27,6 @@ use TYPO3\CMS\Extbase\Service\EnvironmentService;
  */
 class Typo3DbBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 {
-    /**
-     * @var DataMapper
-     */
-    protected static $dataMapper;
-
     public function setUp()
     {
         parent::setUp();
@@ -40,14 +34,6 @@ class Typo3DbBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $GLOBALS['TSFE']->gr_list = '';
     }
 
-    /**
-     * Setup DataMapper
-     */
-    public static function setUpBeforeClass()
-    {
-        self::$dataMapper = new DataMapper();
-    }
-
     /**
      * @return array
      */
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php
index c6b330812155..b69d4517e1a5 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php
@@ -129,4 +129,10 @@ return [
             'Deprecation-82702-SecondArgumentOfGeneralUtilitymkdir_deep.rst',
         ],
     ],
+    'TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper->getPlainValue' => [
+        'maximumNumberOfArguments' => 2,
+        'restFiles' => [
+            'Breaking-83241-ExtbaseRemovedCustomFunctionalityForDataMapper-getPlainValue.rst',
+        ],
+    ],
 ];
-- 
GitLab