Commit 6a9130ec authored by Stefan Bürk's avatar Stefan Bürk Committed by Benni Mack
Browse files

[TASK] Deprecate argument RelationHandler->writeForeignField()

Argument $skipSorting of RelationHandler->writeForeignField()
is used to pass $callFromImpExp from DataHandler.

The ext:impexp related @internal $callFromImpExp DataHandler
property however is never used and thus obsolete itself.

The patch drops DataHandler->$callFromImpExp and deprecates
last RelationHandler->writeForeignField() argument.

Resolves: #95062
Releases: master
Change-Id: If91c2de1e762c97fb50a72c84698a849df807bf2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70848

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 4f46782f
......@@ -537,15 +537,6 @@ class DataHandler implements LoggerAwareInterface
*/
protected $referenceIndexUpdater;
/**
* Tells, that this DataHandler instance was called from \TYPO3\CMS\Impext\ImportExport.
* This variable is set by \TYPO3\CMS\Impext\ImportExport
*
* @var bool
* @internal only used within TYPO3 Core
*/
public $callFromImpExp = false;
// Various
/**
......@@ -3081,10 +3072,8 @@ class DataHandler implements LoggerAwareInterface
$dbAnalysis->start(implode(',', $valueArray), $foreignTable, '', 0, $table, $tcaFieldConf);
// IRRE with a pointer field (database normalization):
if ($tcaFieldConf['foreign_field'] ?? false) {
// if the record was imported, sorting was also imported, so skip this
$skipSorting = (bool)$this->callFromImpExp;
// update record in intermediate table (sorting & pointer uid to parent record)
$dbAnalysis->writeForeignField($tcaFieldConf, $id, 0, $skipSorting);
$dbAnalysis->writeForeignField($tcaFieldConf, $id, 0);
$newValue = $dbAnalysis->countItems(false);
} elseif ($this->getInlineFieldType($tcaFieldConf) === 'mm') {
// In order to fully support all the MM stuff, directly call checkValue_group_select_processDBdata instead of repeating the needed code here
......
......@@ -1040,10 +1040,19 @@ class RelationHandler
* @param array $conf TCA configuration for current field
* @param int $parentUid The uid of the parent record
* @param int $updateToUid If this is larger than zero it will be used as foreign UID instead of the given $parentUid (on Copy)
* @param bool $skipSorting Do not update the sorting columns, this could happen for imported values
* @param bool $skipSorting @deprecated since v11, will be dropped with v12. Simplify the if below when removing argument.
*/
public function writeForeignField($conf, $parentUid, $updateToUid = 0, $skipSorting = false)
public function writeForeignField($conf, $parentUid, $updateToUid = 0, $skipSorting = null)
{
// @deprecated since v11, will be removed with v12.
if ($skipSorting !== null) {
trigger_error(
'Calling ' . __METHOD__ . ' with 4th argument $skipSorting is deprecated and will be removed in v12.',
E_USER_DEPRECATED
);
}
$skipSorting = (bool)$skipSorting;
if ($this->useLiveParentIds) {
$parentUid = $this->getLiveDefaultId($this->currentTable, $parentUid);
if (!empty($updateToUid)) {
......@@ -1112,7 +1121,8 @@ class RelationHandler
if ($foreign_table_field && $this->currentTable) {
$updateValues[$foreign_table_field] = $this->currentTable;
}
// Update sorting columns if not to be skipped
// Update sorting columns if not to be skipped.
// @deprecated since v11, will be removed with v12. Drop if() below, assume $skipSorting false, keep body.
if (!$skipSorting) {
// Get the correct sorting field
// Specific manual sortby for data handled by this field
......
.. include:: ../../Includes.txt
===================================================================================
Deprecation: #95062 - $skipSorting argument of RelationHandler->writeForeignField()
===================================================================================
See :issue:`95062`
Description
===========
To further clean up :php:`TYPO3\CMS\Core\DataHandling\DataHandler`, the unused
internal property :php:`callFromImpExp` has been removed. It's single usage has
been the 4th argument of :php:`TYPO3\CMS\Core\Database\RelationHandler->writeForeignField()`.
Handing over this argument to :php:`RelationHandler->writeForeignField()` has been
marked as deprecated.
Impact
======
Calling :php:`TYPO3\CMS\Core\Database\RelationHandler->writeForeignField()` with
4th argument raises a deprecation level error.
Affected Installations
======================
It is unlikely instances contain extensions using the above argument, since
it carried a core internal information tailored for ext:impexp specific needs.
The extension scanner will find usages as weak match.
Migration
=========
No migration available. Consuming extensions should drop that argument.
Calling RelationHandler->writeForeignField() with non-default true as fourth
argument skipped some relation-sorting related code, which should be avoided.
.. index:: Database, FullyScanned, ext:core
......@@ -303,4 +303,10 @@ return [
'Deprecation-94272-DeprecatedApplication-runCallback.rst',
],
],
'TYPO3\CMS\Core\Database\RelationHandler->writeForeignField' => [
'maximumNumberOfArguments' => 3,
'restFiles' => [
'Deprecation-95062-SkipSortingArgumentOfRelationHandler-writeForeignField.rst',
],
],
];
Supports Markdown
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