Closed rabauss closed 5 years ago
Are you sure dynamicPtable
is actually supported by DC_Multilingual?
@rabauss can you check if 025b567 solves the problem for you?
By the way the tstamp of the language child should always get an update there while updating the primary language, shouldn't it?
I think it shouldn't be copied because tstamp
reflects the last change of certain record (i.e. language record). So the language record could be edited in May and the main record in June. No need to sync that in my opinion.
Well, our solution would look like this:
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dynamicPtable']) {
$objCurrent = \Database::getInstance()->prepare(
"SELECT pid, ptable FROM ".$this->strTable." WHERE id=?"
)
->limit(1)
->execute($this->intId);
$intPid = ($objCurrent->numRows) ? $objCurrent->pid : 0;
$pTable = ($objCurrent->numRows) ? $objCurrent->ptable : '';
$intId = \Database::getInstance()->prepare(
"INSERT INTO ".$this->strTable." ({$this->pidColumnName},tstamp,{$this->langColumnName},pid,ptable) VALUES (?,?,?,?,?)"
)
->execute($this->intId, time(), $language, $intPid, $pTable)
->insertId;
} else {
because the current entry has to be selected with ptable!
Why is that if I may ask? $this->ptable
should always match $objCurrent->ptable
, no?
Yes, you're right the ptable should match. But I think the variable was sometimes not set.
I guess because in our DCA it's dynamic with something like that:
'ptable' => \Input::get('ptable') ?? '',
and the get variable was not set on post reload of language selector. I'm not sure anymore but I had some struggle with that variable.
If that was the case then the source of the problem must have been in a different place I think. When you have chance to find out the problem again, let me know. For now I will release my fix 👍🏻
We had some trouble with DC Multilingual and dynamicPtable. Unfortunately the
ptable
will not preserved for the languageChildren. And so the children could get deleted byDC_Table -> reviseTable
, if you have an sql default for theptable
field! If I think again about it, then the following problem would not occur with empty default for ptable.For the insert the
ptable
should also get loaded and set - somewhere here: https://github.com/terminal42/contao-DC_Multilingual/blob/35fe458c1b3bc1fced8461ad9f0ec36735f3ba6f/src/Driver.php#L1211On the update of
tstamp
theptable
will only get set on the primary language (because$this->id
is not the language ID) https://github.com/terminal42/contao-DC_Multilingual/blob/35fe458c1b3bc1fced8461ad9f0ec36735f3ba6f/src/Driver.php#L477By the way the
tstamp
of the language child should always get an update there while updating the primary language, shouldn't it?