Bug #16393

Workspaces loses MM relations on saving a new record and publish a draft record.

Added by Zach Davis over 14 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
Workspaces
Target version:
-
Start date:
2006-07-21
Due date:
% Done:

0%

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

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

class.t3lib_tcemain.php (233 KB) class.t3lib_tcemain.php Administrator Admin, 2006-07-21 19:49
tcemain_patch4_1_1.diff (1.6 KB) tcemain_patch4_1_1.diff Administrator Admin, 2007-06-14 11:53
tt_news_patch2_5_0.diff (4.01 KB) tt_news_patch2_5_0.diff Administrator Admin, 2007-06-14 11:54
as_mmswap-typo3-4.1.3-0_0_1-z-200711150100.t3x (5.75 KB) as_mmswap-typo3-4.1.3-0_0_1-z-200711150100.t3x Administrator Admin, 2007-11-15 01:08
as_mmswap-typo3-4.2-0_0_1-z-200711150100.t3x (5.9 KB) as_mmswap-typo3-4.2-0_0_1-z-200711150100.t3x Administrator Admin, 2007-11-15 01:08
as_mmswap-typo3-4.1.3-ttnewssup-0_0_1-z-200711150100.t3x (5.86 KB) as_mmswap-typo3-4.1.3-ttnewssup-0_0_1-z-200711150100.t3x Administrator Admin, 2007-11-16 04:37

Related issues

Related to TYPO3 Core - Bug #16166: Publishing a record breaks dam_ttcontent-relationsClosedKasper Skaarhoj2006-05-22

Actions
#1

Updated by Andreas Wolf over 14 years ago

This bug seems to be related to 3531. Perhaps Zach's fix is even more applicable than mine - could someone check this?

#2

Updated by Wolfgang Klinger over 14 years ago

This patch works generally, but there's something important missing:

either

if ($table == 'tt_content') {
....
}
or
if ($table != 'pages') {
....
}

around the lines
whatever you find more appropriate!

Because if this is applied to a page you get into more troubles: if you create the page with the "big button" New page in the "Page" module and create a content element immediately afterwards the content is tied to the placeholder page and not the draft one and so the content elements "disappear".

#3

Updated by Wolfgang Klinger over 14 years ago

someone should take care of this and implement the patch

#4

Updated by Michael Stucki over 14 years ago

Changing the priority for this.

#5

Updated by Andreas Wolf over 14 years ago

Hm, I think, it should be the second of Wolfgang's two options, because the first doesn't affect other versionized tables, so e.g. tt_news would still be affected by the new bug my patch introduced.

#6

Updated by Thomas Buss almost 14 years ago

Of course, the Patch works generally, but after installing, in templa voila all new content elements from users in a workspace are always inserted as reference. So I had to remove the patch to get my editors work normally.

#7

Updated by Andreas Wolf almost 14 years ago

Thomas, which version of TV do you use? pre-1.3-versions had a bug that created all new content-elements as references (see #3143) . This is fixed in 1.3.

#8

Updated by Thomas Buss almost 14 years ago

I use 4.0.4 with TV 1.3. The only thing of Zach´s code I added is the recommended if clause against 'pages'.

The error occurs only in a custom workspace. In a live workspace the patch works fine.

#9

Updated by Nabil Saleh over 13 years ago

I am experiencing the same Problems in typo3 4.1.1 with tt_news(2.5.0) mm-relations to categories.
Will this be fixed in the core in near future?

#10

Updated by Thomas Buss over 13 years ago

I can confirm the issue with tt_news. Categories of news-items are lost after publishing!

This makes tt_news nearly unusable in a workspace-enviroment, because the categories must be added manually in live-workspace after publishing.

#11

Updated by Nabil Saleh over 13 years ago

Okay meanwhile I fixed this for me (tcemain_patch4_1_1.diff &tt_news_patch2_5_0.diff) , but I think the query s I manipulated in tt_news slow things down! I cant't optimize this atm but at least it works.

#12

Updated by Administrator Admin over 13 years ago

thanks, for the patch.
But I have the prob, that after installing the patch everything else in the workspace won't function. All content elements will get lost after live switching. Very bad.
I made this little very, very dirty hack for tt_news. So it works only for tt_news.

class.t3lib_tcemain.php

// NSA ZACH PATCH BEGIN
if(strpos($TCA[$table]['ctrl']['title'], "tt_news")){
$this->substNEWwithIDs[$id] = $phShadowId;
}
// NSA ZACH PATCH END

please excuse my bad english and my little programming skills

#13

Updated by Andreas about 13 years ago

Problem is still virulent in the neXt Typo3 Version 4.2.0alpha1!!!!
Let's start a run on this medusalem bug.
The trophy of 100bugs, I mean Euro will wait for a working patch, which we exceptionally can slip the developer team (despite feature freeze) - this should be happen the next two weeks or so, I guess. Hope you (mr. or mrs. core developer) will support this.
*A.

#14

Updated by Zach Davis about 13 years ago

Cast Iron Coding will put up another 50 euro to sponsor this issue. Let's get it fixed, as it's really stopping us from encouraging our clients to fully adopt workspaces.

#15

Updated by Andreas about 13 years ago

Try this Zach, and let me know if it works, or send me your extension where the mm tables are in. works for me at the few mm tables i've tested - for pages or content elements.
look at the typo3 version. tested this only for typo3 4.1.3 & the 4.2 alpha1

#16

Updated by Thomas Buss about 13 years ago

Thanks Andreas, but your extension has no effect on my typo3 4.1.3.

News categories are still lost after publishing news entries from workspaces.

#17

Updated by Andreas about 13 years ago

hello thomas buss, it took some time to figure it out - as_mmswap-typo3-4.1.3-ttnewssup-0_0_1. if it works for you please support this ;-) . what i know you need the latest tt_news (2.5) version for element versioning.
prix (at) typotemp.com

#18

Updated by Francois Suter about 13 years ago

I have tried the patch for dam_ttcontent and not dam_ttnews (but it should be the same problem since both are two-way MM fields). Unfortunately the patch does not work for me. It doesn't seem to have any effect :-(

#19

Updated by Francois Suter about 13 years ago

Tested with 4.1.4 and 4.1.5-dev

#20

Updated by Andreas about 13 years ago

Hello Francois,
These extensions doesn't work with the typo3 MM system, and this path right now just look on publishing if there is a MM table registered in the table to publish. Kasper nows of this problem (MM tables & workflow) - prob. it will be solved until february next year. If I will find time I'll have another look at it. even though - try to keep up good mood.

#21

Updated by Administrator Admin almost 13 years ago

I have been looking at a related bug

If you have a mm reference in table A to something that is in draft mode in table B and then publish the object in table B it breaks the mm reference.

I think a solution to this is to trawl all the way through the $TCA looking for anything with a type = 'db' and an 'allowed' that includes table B. Then if it is a MM relation updating the MM table or if it isn't updating the field in table A

I am trying this, but at the moment it appears that the dynamic part of the TCA for a lot of the tables isn't being loaded. Is there any way of forcing it to load?

thanks

#22

Updated by Ingo Renner almost 13 years ago

Hi all,

please check whether this has been fixed with Kasper's latest changes in trunk or the upcoming 4.2 beta1. If that is the case please provide some feedback here, so that we can mark this issue as resolved.

#23

Updated by Administrator Admin almost 13 years ago

I agree. I have reported my patch back to issue 3531 but it also solves the problems described here. So I think you can close it!

#24

Updated by Administrator Admin almost 13 years ago

... oh, and maybe Zach and Andreas wants to know where to send the money...? :-) Please send me an email about it.

#25

Updated by Ingo Renner almost 13 years ago

fixed by Kasper in 4.2beta1

#26

Updated by Michael Stucki about 7 years ago

  • Category set to Workspaces
#27

Updated by Michael Stucki about 7 years ago

  • Project changed from Workspaces & Versioning to TYPO3 Core
  • Category changed from Workspaces to Workspaces
  • Target version deleted (0)

Also available in: Atom PDF