Commit db8d5dcb authored by Benni Mack's avatar Benni Mack Committed by Daniel Goerz
Browse files

[BUGFIX] Ensure FormEngine IRRE handles relations in workspace

FormEngine does not show and handle IRRE records when they are
deleted (connected records from the live workspace are shown).

When removal and refactoring of code in this ares was done for
v9, "too much" code got removed. Which is why workspace overlays
are not handled properly anymore.

In addition, the ElementInformationController now correctly
resolves a workspace record when finding the pageInfo and access.

Resolves: #88502
Related: #82634
Releases: master, 9.5
Change-Id: Ib2d70ffa92c78752626b43ec5012d9dba036e7b8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60890

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Achim Fritz's avatarAchim Fritz <af@achimfritz.de>
Tested-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Achim Fritz's avatarAchim Fritz <af@achimfritz.de>
Reviewed-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
parent 1face766
......@@ -171,7 +171,11 @@ class ElementInformationController
} else {
$this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
if ($this->row) {
$this->pageInfo = BackendUtility::readPageAccess($this->row['pid'], $this->permsClause);
// Find the correct "pid" when a versionized record is given, otherwise "pid = -1" always fails
if (!empty($this->row['t3ver_oid'])) {
$t3OrigRow = BackendUtility::getRecord($this->table, (int)$this->row['t3ver_oid']);
$this->pageInfo = BackendUtility::readPageAccess((int)$t3OrigRow['pid'], $this->permsClause);
}
$this->access = is_array($this->pageInfo);
}
}
......
......@@ -36,6 +36,9 @@ class DatabaseParentPageRow extends AbstractDatabaseRecordProvider implements Fo
if ($result['vanillaUid'] < 0) {
// vanillaUid points to a neighbor record in same table - get its record and its pid from there to find parent record
$neighborRow = $this->getRecordFromDatabase($result['tableName'], abs($result['vanillaUid']));
if (!empty($neighborRow['t3ver_oid'])) {
$neighborRow = $this->getRecordFromDatabase($result['tableName'], (int)$neighborRow['t3ver_oid']);
}
$result['neighborRow'] = $neighborRow;
// uid of page the record is located in
$neighborRowPid = (int)$neighborRow['pid'];
......
......@@ -123,7 +123,7 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
* @param string $fieldName Current handle field name
* @return array Modified item array
*/
protected function resolveRelatedRecords(array $result, $fieldName)
protected function resolveRelatedRecordsOverlays(array $result, $fieldName)
{
$childTableName = $result['processedTca']['columns'][$fieldName]['config']['foreign_table'];
......@@ -137,6 +137,7 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
);
}
$result['databaseRow'][$fieldName] = implode(',', $connectedUidsOfLocalizedOverlay);
$connectedUidsOfLocalizedOverlay = $this->getWorkspacedUids($connectedUidsOfLocalizedOverlay, $childTableName);
if ($result['inlineCompileExistingChildren']) {
$tableNameWithDefaultRecords = $result['tableName'];
$connectedUidsOfDefaultLanguageRecord = $this->resolveConnectedRecordUids(
......@@ -145,6 +146,7 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
$result['defaultLanguageRow']['uid'],
$result['defaultLanguageRow'][$fieldName]
);
$connectedUidsOfDefaultLanguageRecord = $this->getWorkspacedUids($connectedUidsOfDefaultLanguageRecord, $childTableName);
$showPossible = $result['processedTca']['columns'][$fieldName]['config']['appearance']['showPossibleLocalizationRecords'];
......@@ -202,6 +204,40 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
return $result;
}
/**
* Substitute the value in databaseRow of this inline field with an array
* that contains the databaseRows of currently connected records and some meta information.
*
* @param array $result Result array
* @param string $fieldName Current handle field name
* @return array Modified item array
*/
protected function resolveRelatedRecords(array $result, $fieldName)
{
if ($result['defaultLanguageRow'] !== null) {
return $this->resolveRelatedRecordsOverlays($result, $fieldName);
}
$childTableName = $result['processedTca']['columns'][$fieldName]['config']['foreign_table'];
$connectedUidsOfDefaultLanguageRecord = $this->resolveConnectedRecordUids(
$result['processedTca']['columns'][$fieldName]['config'],
$result['tableName'],
$result['databaseRow']['uid'],
$result['databaseRow'][$fieldName]
);
$result['databaseRow'][$fieldName] = implode(',', $connectedUidsOfDefaultLanguageRecord);
$connectedUidsOfDefaultLanguageRecord = $this->getWorkspacedUids($connectedUidsOfDefaultLanguageRecord, $childTableName);
if ($result['inlineCompileExistingChildren']) {
foreach ($connectedUidsOfDefaultLanguageRecord as $uid) {
$compiledChild = $this->compileChild($result, $fieldName, $uid);
$result['processedTca']['columns'][$fieldName]['children'][] = $compiledChild;
}
}
return $result;
}
/**
* If there is a foreign_selector or foreign_unique configuration, fetch
* the list of possible records that can be connected and attach the to the
......
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