Project

General

Profile

Actions

Bug #88153

closed

Deleted translations still show up in language selector

Added by Robert Vock about 5 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Workspaces
Target version:
-
Start date:
2019-04-15
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

Deleted-Element-in-workspace.png (29.8 KB) Deleted-Element-in-workspace.png Robert Vock, 2019-04-15 15:46
Correct.png (31.7 KB) Correct.png Robert Vock, 2019-04-15 15:53
cattura.png (247 KB) cattura.png Riccardo De Contardi, 2020-07-25 13:13
cattura2.png (39.8 KB) cattura2.png Riccardo De Contardi, 2020-07-25 13:15

Updated by Riccardo De Contardi almost 4 years ago

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

Actions #2

Updated by Christian Kuhn over 3 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.

Actions #3

Updated by Gerrit Code Review over 3 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

Actions #4

Updated by Christian Kuhn over 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #5

Updated by Gerrit Code Review over 3 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

Actions #6

Updated by Gerrit Code Review over 3 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

Actions #7

Updated by Christian Kuhn over 3 years ago

  • Status changed from Under Review to Resolved
Actions #8

Updated by Benni Mack about 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF