...
 
Commits (2)
......@@ -2654,24 +2654,35 @@ class DataHandler
*/
public function getUnique($table, $field, $value, $id, $newPid = 0)
{
// If the field is configured in TCA, proceed:
if (is_array($GLOBALS['TCA'][$table]) && is_array($GLOBALS['TCA'][$table]['columns'][$field])) {
$newValue = $value;
$statement = $this->getUniqueCountStatement($newValue, $table, $field, (int)$id, (int)$newPid);
// For as long as records with the test-value existing, try again (with incremented numbers appended)
if ($statement->fetchColumn()) {
for ($counter = 0; $counter <= 100; $counter++) {
$newValue = $value . $counter;
$statement->bindValue(1, $newValue);
$statement->execute();
if (!$statement->fetchColumn()) {
break;
}
if (!is_array($GLOBALS['TCA'][$table]) || !is_array($GLOBALS['TCA'][$table]['columns'][$field])) {
// Field is not configured in TCA
return $value;
}
if ((string)$GLOBALS['TCA'][$table]['columns'][$field]['l10n_mode'] === 'exclude') {
$transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
$l10nParent = (int)$this->checkValue_currentRecord[$transOrigPointerField];
if ($l10nParent > 0) {
// Current record is a translation and l10n_mode "exclude" just copies the value from source language
return $value;
}
}
$newValue = $value;
$statement = $this->getUniqueCountStatement($newValue, $table, $field, (int)$id, (int)$newPid);
// For as long as records with the test-value existing, try again (with incremented numbers appended)
if ($statement->fetchColumn()) {
for ($counter = 0; $counter <= 100; $counter++) {
$newValue = $value . $counter;
$statement->bindValue(1, $newValue);
$statement->execute();
if (!$statement->fetchColumn()) {
break;
}
}
$value = $newValue;
}
return $value;
return $newValue;
}
/**
......
"pages",,,,,,,,,,,
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title"
,1,0,256,0,0,0,0,0,0,0,"FunctionalTest"
,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest"
,89,88,256,0,0,0,0,0,0,0,"Relations"
,90,88,512,0,0,0,0,0,0,0,"Target"
"pages",,,,,,,,,,,,
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title","keywords"
,1,0,256,0,0,0,0,0,0,0,"FunctionalTest","functional"
,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest","datahandler"
,89,88,256,0,0,0,0,0,0,0,"Relations","relations"
,90,88,512,0,0,0,0,0,0,0,"Target","target"
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase;
class GetUniqueTranslationTest extends AbstractDataHandlerActionTestCase
{
/**
* @var int
*/
const PAGE_DATAHANDLER = 88;
/**
* @var string
*/
protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/DataSet/';
protected function setUp()
{
parent::setUp();
$this->importScenarioDataSet('LiveDefaultPages');
$this->importScenarioDataSet('LiveDefaultElements');
$this->backendUser->workspace = 0;
}
/**
* @test
*/
public function valueOfUniqueFieldExcludedInTranslationIsUntouchedInTranslation()
{
$GLOBALS['TCA']['pages_language_overlay']['columns']['keywords']['l10n_mode'] = 'exclude';
$map = $this->actionService->localizeRecord('pages', self::PAGE_DATAHANDLER, 1);
$newPageId = $map['pages_language_overlay'][self::PAGE_DATAHANDLER];
$originalLanguageRecord = BackendUtility::getRecord('pages', self::PAGE_DATAHANDLER);
$translatedRecord = BackendUtility::getRecord('pages_language_overlay', $newPageId);
$this->assertEquals('datahandler', $originalLanguageRecord['keywords']);
$this->assertEquals('datahandler', $translatedRecord['keywords']);
}
}
......@@ -438,7 +438,7 @@ NOW Running --AUTOFIX on result. OK?' . ($this->cli_isArg('--dryrun') ? ' (--dry
}
if (!$this->genTree_traverseDeleted) {
$queryBuilder->getRestrictions()->add(DeletedRestriction::class);
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
}
$result = $queryBuilder->execute();
......@@ -551,7 +551,7 @@ NOW Running --AUTOFIX on result. OK?' . ($this->cli_isArg('--dryrun') ? ' (--dry
$queryBuilder->getRestrictions()->removeAll();
if (!$this->genTree_traverseDeleted) {
$queryBuilder->getRestrictions()->add(DeletedRestriction::class);
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
}
$queryBuilder
......