[!!!][TASK] Remove custom userfunc of DataMapper->getPlainValue 37/54837/3
authorBenni Mack <benni@typo3.org>
Tue, 28 Nov 2017 17:08:07 +0000 (18:08 +0100)
committerBenni Mack <benni@typo3.org>
Fri, 8 Dec 2017 05:42:08 +0000 (06:42 +0100)
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>
typo3/sysext/core/Documentation/Changelog/master/Breaking-83241-ExtbaseRemovedCustomFunctionalityForDataMapper-getPlainValue.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php

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 (file)
index 0000000..ee6a369
--- /dev/null
@@ -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
index d26d367..b07bcc5 100644 (file)
@@ -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;
-    }
 }
index 12e0986..cf3934a 100644 (file)
@@ -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();
@@ -41,14 +35,6 @@ class Typo3DbBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     }
 
     /**
-     * Setup DataMapper
-     */
-    public static function setUpBeforeClass()
-    {
-        self::$dataMapper = new DataMapper();
-    }
-
-    /**
      * @return array
      */
     public function uidOfAlreadyPersistedValueObjectIsDeterminedCorrectlyDataProvider(): array
index c6b3308..b69d451 100644 (file)
@@ -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',
+        ],
+    ],
 ];