Issue Bug Closed

#38063Content elements disappear on publishing a page

Andreas Kießling 06/15/12, 09:24 updated 10/23/17, 22:20

Description

With #30604 a severe Bug in 4.7 was introduced with these effects:

  • content on a newly created page in a workspace will not be shown in the page module (but is inserted like it should twice in the db (INITIAL PLACEHOLDER and First draft version)
  • after publishing the page and the content, both content elements are deleted from the db (not just marked deleted, but really deleted)

This is caused by the missing t3ver_swapmode in TCEmain: (code from 4.5)

$fieldArray['pid'] = -1;
$fieldArray['t3ver_oid'] = $this->substNEWwithIDs[$id];
$fieldArray['t3ver_id'] = 1;
$fieldArray['t3ver_state'] = -1; // Setting placeholder state value for version (so it can know it is currently a new version...)
$fieldArray['t3ver_label'] = 'First draft version';
$fieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
if ($table === 'pages') { // Swap mode set to "branch" so we can build branches for pages.
    $fieldArray['t3ver_swapmode'] = $versioningType;
}
$phShadowId = $this->insertDB($table, $id, $fieldArray, TRUE, 0, TRUE); 

TCA ref says, that t3ver_swapmode is exclusive to pages, so it would be ok to remove the field, if there were not over 30 occurances of t3ver_swapmode throughout the core.
With 0 in that field, the wrong page record / id is fetched in these cases, since i guess it behaves like newPagesVersioningType was set to 0 (page) which is “known for the drawbacks of loosing ids”

Quick fix: reintroduce 3 lines to always set t3ver_swapmode to -1 for the workspace pages

$fieldArray['t3ver_label'] = 'First draft version';
$fieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
if ($table === 'pages') {
    $fieldArray['t3ver_swapmode'] = -1;
}
$phShadowId = $this->insertDB($table, $id, $fieldArray, TRUE, 0, TRUE); // 

Real fix: all checks/occurences of t3ver_swapmode must be adopted to behave like this was set to -1

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.