Skip to content

Commit

Permalink
[TASK] Deprecate argument RelationHandler->writeForeignField()
Browse files Browse the repository at this point in the history
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 <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
sbuerk authored and bmack committed Sep 1, 2021
1 parent 4f46782 commit 6a9130e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 15 deletions.
13 changes: 1 addition & 12 deletions typo3/sysext/core/Classes/DataHandling/DataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -3081,10 +3072,8 @@ protected function checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $
$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
Expand Down
16 changes: 13 additions & 3 deletions typo3/sysext/core/Classes/Database/RelationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1040,10 +1040,19 @@ protected function readForeignField($uid, $conf)
* @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)) {
Expand Down Expand Up @@ -1112,7 +1121,8 @@ public function writeForeignField($conf, $parentUid, $updateToUid = 0, $skipSort
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.. 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
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,10 @@
'Deprecation-94272-DeprecatedApplication-runCallback.rst',
],
],
'TYPO3\CMS\Core\Database\RelationHandler->writeForeignField' => [
'maximumNumberOfArguments' => 3,
'restFiles' => [
'Deprecation-95062-SkipSortingArgumentOfRelationHandler-writeForeignField.rst',
],
],
];

0 comments on commit 6a9130e

Please sign in to comment.