Skip to content

Commit 20827d3

Browse files
committedMay 5, 2014
Convert binary UUIDs in DC_File before saving (see contao#6893)
1 parent 78c18d8 commit 20827d3

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed
 

‎system/modules/core/drivers/DC_File.php

+29-16
Original file line numberDiff line numberDiff line change
@@ -401,30 +401,43 @@ protected function save($varValue)
401401
$varValue = $varValue ? true : false;
402402
}
403403

404-
// Convert date formats into timestamps
405-
if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim')))
404+
if ($varValue != '')
406405
{
407-
$objDate = new \Date($varValue, \Config::get($arrData['eval']['rgxp'] . 'Format'));
408-
$varValue = $objDate->tstamp;
409-
}
406+
// Convert binary UUIDs (see #6893)
407+
if ($arrData['inputType'] == 'fileTree')
408+
{
409+
$varValue = deserialize($varValue);
410410

411-
// Handle entities
412-
if ($arrData['inputType'] == 'text' || $arrData['inputType'] == 'textarea')
413-
{
414-
$varValue = deserialize($varValue);
411+
if (!is_array($varValue))
412+
{
413+
$varValue = \String::binToUuid($varValue);
414+
}
415+
else
416+
{
417+
$varValue = serialize(array_map('String::binToUuid', $varValue));
418+
}
419+
}
415420

416-
if (!is_array($varValue))
421+
// Convert date formats into timestamps
422+
if (in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim')))
417423
{
418-
$varValue = \String::restoreBasicEntities($varValue);
424+
$objDate = new \Date($varValue, \Config::get($arrData['eval']['rgxp'] . 'Format'));
425+
$varValue = $objDate->tstamp;
419426
}
420-
else
427+
428+
// Handle entities
429+
if ($arrData['inputType'] == 'text' || $arrData['inputType'] == 'textarea')
421430
{
422-
foreach ($varValue as $k=>$v)
431+
$varValue = deserialize($varValue);
432+
433+
if (!is_array($varValue))
423434
{
424-
$varValue[$k] = \String::restoreBasicEntities($v);
435+
$varValue = \String::restoreBasicEntities($varValue);
436+
}
437+
else
438+
{
439+
$varValue = serialize(array_map('String::restoreBasicEntities', $varValue));
425440
}
426-
427-
$varValue = serialize($varValue);
428441
}
429442
}
430443

0 commit comments

Comments
 (0)
Please sign in to comment.