Bug #16393
closedWorkspaces loses MM relations on saving a new record and publish a draft record.
0%
Description
Steps to reproduce:
1. User makes new record with MM relations in draft workspace. User saves record.
2. On save, TCEMAIN calls $this->dbAnalysisStoreExec() to update the relations in any MM tables. Unforunfately, the local_uid that is stored in these tables is that of the placeholder record and not of the draft record. After saving, all MM relations in the draft record are lost.
3. On editing the draft record, user can add new MM relations and save the record. Because this is not a new record at this point, the MM relations in the draft will be saved.
4. On publishing the draft record, all MM relations between the draft and another record remain the same. The live version is not updated with the draft's MM relations.
Solution:
Part 1:
We need to update $this->substNEWwithIDs in TCEMAIN's process_datamap method with the UID of the draft record on save:
I believe this:
$phShadowId = $this->insertDB($table,$id,$fieldArray,TRUE,0,TRUE); // When inserted, $this->substNEWwithIDs[$id] will be changed to the uid of THIS version and so the interface will pick it up just nice!
should be changed to this:
$phShadowId = $this->insertDB($table,$id,$fieldArray,TRUE,0,TRUE); // When inserted, $this->substNEWwithIDs[$id] will be changed to the uid of THIS version and so the interface will pick it up just nice!
$this->substNEWwithIDs[$id] = $phShadowId;
Furthermore, on publishing, we need to replace the live (placeholder) record's MM relations with the relations of the draft record and, furthermore, the MM relations in the draft record need to be removed from the MM tables.
So, in TCEMAIN's version_swap method, immediately after the swapping is executed, we can add the following to acocmplish this:
$row = $this->recordInfo($table,intval($swapWith),'*');
foreach($row as $field => $value) {
$conf = $TCA[$table]['columns'][$field]['config'];
if (is_array($conf)) {
if($conf['MM'] == true) {
$str = $this->copyRecord_procBasedOnFieldType($table,$swapWith,$field,$value,$row,$conf);
$valueArr = explode(',',$str);
$this->checkValue_group_select_processDBdata($valueArr,$conf,$id,'update',$conf['type']);
}
}
}
I'm attaching a revised version of TCEMAIN -- search for ZACH to see my two changes. Hope this helps...
--Zach
(issue imported from #M3907)
Files