[TYPO3-dam-devel] Reverting "bugfix" for #7344

Ingo Renner ingo at typo3.org
Tue May 27 10:31:53 CEST 2008


Hi all,

the fix I provided for #7344 now causes some trouble as I just 
experienced, let me explain in which way, and what the consequences are:

Issue 7344: http://bugs.typo3.org/view.php?id=7344

So I was trying to get the workspace module to show differences of the 
DAM media field for content elements when using dam_ttcontent. The 
problem the patch causes now is that although requesting the referenced 
files for the LIVE version of a content element DAM would always return 
the files referenced by the DRAFT version of the content element.

The reason is the patch I provided for issue 7344 *always* tries to 
resolve the DRAFT version of a record if one exists - it simply doesn't 
know that I need/want to have the LIVE version in this case.

So what are the consequences? There are three solutions for the problem, 
one very ugly, one less ugly but still not quite ok, and one most likely 
correct solution (in the sense of TYPO3 and workspaces).


Solution 1 (the very ugly):
Add a new parameter to the already long list of function parameters for 
tx_dam_db->getReferencedFiles() and subsequently 
tx_dam_db->referencesQuery() and most likely all other methods that 
would call referencesQuery()

Solution 2 (less ugly, quite ok, but doesn't feel good in the first place):
Add a (maybe static) class member for tx_dam_db named 
$enableWorkspaceSupport which is set to "true" by default. 
tx_dam_db->referencesQuery() would then check that variable and could 
turn off workspace support if needed. In most cases the default should 
be ok, but as explained above we need to get the raw meat sometimes.

Solution 3 (most likely the correct TYPO3 way):
Revert the patch completly - in fact I'd say that the method was working 
correct the way it was after experiencing the side effects.
However then we would have the old behavior back that seems faulty at 
first glance. The "real" TYPO3 way solution is then to call one of 
t3lib_BEfunc's methods to handle workspaces before calling the DAM methods.
In case of dam_ttcontent that would look like this:


   // resolving the DRAFT version uid if any
$row = t3lib_BEfunc::getWorkspaceVersionOfRecord(
   $GLOBALS['BE_USER']->workspace,
   'tt_content',
   $row['uid']
);

   // gets the files for the CE
$filesArray = tx_dam_db::getReferencedFiles(
   'tt_content',
   $row['uid'],
   $config['MM_match_fields'],
   $config['MM'],
   'tx_dam.*'
);

So basically this would mean to call one of the t3lib_BEfunc workspace 
handling methods in all places where we need workspace support. However 
I think this is the most correct solution as we then do not need to care 
for the workspace implementation on our own as the core takes care of 
it. Also in case something changes with the core's workspace 
implementation - as it was the case with TYPO3 4.2 - we do not have to 
adopt those changes but get them automatically.


Please let me know which solution you'd prefer. I myself tend to 
solution #3 although this means some work. As we need to get DAM fixed 
in conjunction with workspaces anyways I'd also do that of course and 
find the places where we need to add the calls to t3lib_BEfunc.


all the best
Ingo

-- 
Ingo Renner
TYPO3 Core Developer, Release Manager TYPO3 4.2


More information about the TYPO3-team-dam mailing list