Skip to content
Snippets Groups Projects
Commit e44470fb authored by Benni Mack's avatar Benni Mack
Browse files

[!!!][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: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarSusanne Moog <susanne.moog@typo3.org>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarDaniel Gorges <daniel.gorges@b13.de>
Tested-by: default avatarDaniel Gorges <daniel.gorges@b13.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
parent 7b179396
Branches
Tags
No related merge requests found
.. 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
......@@ -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;
}
}
......@@ -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
*/
......
......@@ -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',
],
],
];
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment