Bug #88153
closedDeleted translations still show up in language selector
100%
Description
When you delete a translation of a content element in a workspace, that translation still appears in the language selector when editing the original element or another translation which has not been deleted. This is because the language selector does not remove elements which have a DELETE placeholder in the current workspace.
Steps to reproduce:
1. Create a content element with a translation
2. Switch to workspace and delete the translation
3. Edit the original element in the workspace
The language selector still shows the translation.
This bug appears in current master, TYPO3 9 and 8. I didn't test in TYPO3 7, but would suspect it's affected as well.
Buggy code location:
EditDocumentController.php:L2034
I am not sure what the "correct" way to fix this is. In some parts of the Core Backend::getWorkspaceVersionOfRecord is used. In other parts BackendUtility::workspaceOL is used:
LocalizationController.php:L146
TcaInline.php:L384
If the approach of TcaInline should be used, the correct code would look like this:
$backendUser = $this->getBackendUser();
while ($row = $result->fetch()) {
if ($backendUser->workspace !== 0 && BackendUtility::isTableWorkspaceEnabled($table)) {
$workspaceVersion = BackendUtility::getWorkspaceVersionOfRecord($backendUser->workspace, $table, $row['uid'], 'uid,t3ver_state');
if (!empty($workspaceVersion)) {
$versionState = VersionState::cast($workspaceVersion['t3ver_state']);
if ($versionState->equals(VersionState::DELETE_PLACEHOLDER)) {
continue;
}
}
}
$rowsByLang[$row[$languageField]] = $row;
}
But: This only fixes the selector. When this fix is applied, the selector looks like Correct.png. But when you then try to create a new translation, you get the following error:
1: Localization failed: there already are localizations (2) for language 1 of the "tt_content" record 1!
This is another bug, because creating a translation also does not check for deleted elements in the workspace:
BackendUtility.php:L304
BackendUtility::getRecordLocalization should probably also apply the workspaceOverlay.
Files
Updated by Riccardo De Contardi over 4 years ago
- File cattura.png cattura.png added
- File cattura2.png cattura2.png added
The issue is still reproducible on 11.0.0-dev (latest master) with the following procedure
Prerequisites¶
- fresh TYPO3 installation with two languages (in my case ITA and ENG
- custom "Draft" workspace
Test procedure:¶
1) Default language (ITA), Live workspace > Create a new "Test 88153" page
2) Create a "Headline" content element inside of it; headline: "Test 88153 Content in ITA"
3) Create translation for the page in ENG ("Test 88153 in ENG")
4) Translate the content element (I used "connected" mode) "Test 88153 Content in ENG"
5) Switch to "Draft" workspace
6) Delete the translated content element "Test 88153 Content in ENG"
7) while in the draft workspace, switch to "column" mode
8) Edit "Test 88153 Content in ITA"
Result¶
the dropdown at the top still shows "english", too
please not that the english element
- is editable (you can for example change its headline, and no error occurs)
- is not shown on the "languages" view
- but is shown in "list" view, and with the "restore" icon
Updated by Christian Kuhn over 4 years ago
I played forth and back on this for a while now. Your patch works (and the patch strategy is ok) with a minor adaption: The main query must use WorkspaceRestriction instead of BackendWorkspaceRestriction now, that's a fallout of the pid=-1 change.
The follow-up issue as already mentioned by Robert is: Trying to create a new translation from within the drop-down then leads to DataHandler issue "Localization failed" (which is technically correct), and then FormEngine opens the delete placeholder record and allows editing it. This needs to be supressed: A message "Please either discard or publish the delete placeholder record before you can create a new translation record" or similar should be rendered instead.
I'll continue to work on this issue but may need a couple of pre-patches to ultimately solve it.
Updated by Gerrit Code Review almost 4 years ago
- Status changed from New to Under Review
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67325
Updated by Christian Kuhn almost 4 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset f5ad354558b6ee4a724d0d6f57e8e7be88262f39.
Updated by Gerrit Code Review almost 4 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67341
Updated by Gerrit Code Review almost 4 years ago
Patch set 2 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67341
Updated by Christian Kuhn almost 4 years ago
- Status changed from Under Review to Resolved
Applied in changeset c6e5fbcc70a4cc442018dccef0fcad40a03eb804.