kopia lustrzana https://github.com/nextcloud/social
avoid empty boolean value
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/563/head
rodzic
0b4e325838
commit
4f54b0cae5
|
@ -1161,6 +1161,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep {
|
|||
* @param string $source
|
||||
* @param string $dest
|
||||
* @param array $fields
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function duplicateTable(
|
||||
ISchemaWrapper $schema, string $source, string $dest, array $fields
|
||||
|
@ -1200,6 +1202,13 @@ class Version0002Date20190506000001 extends SimpleMigrationStep {
|
|||
'published_time'
|
||||
];
|
||||
|
||||
$booleanFields = [
|
||||
'local',
|
||||
'public',
|
||||
'accepted',
|
||||
'hidden_on_timeline'
|
||||
];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$value = $this->get($field, $data, '');
|
||||
if ($field === 'id_prim'
|
||||
|
@ -1207,19 +1216,23 @@ class Version0002Date20190506000001 extends SimpleMigrationStep {
|
|||
&& $this->get('id', $data, '') !== '') {
|
||||
$value = hash('sha512', $this->get('id', $data, ''));
|
||||
}
|
||||
|
||||
|
||||
if (in_array($field, $datetimeFields) && $value === '') {
|
||||
$insert->setValue(
|
||||
$field,
|
||||
$insert->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
||||
);
|
||||
} else if (in_array($field, $booleanFields) && $value === '') {
|
||||
$insert->setValue(
|
||||
$field, $insert->createNamedParameter('0')
|
||||
);
|
||||
} else {
|
||||
$insert->setValue(
|
||||
$field, $insert->createNamedParameter($value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$insert->execute();
|
||||
} catch (UniqueConstraintViolationException $e) {
|
||||
|
|
Ładowanie…
Reference in New Issue