Skip to content

Commit a0fcfc1

Browse files
authored
Exporter: Handle NULL values properly (#286)
1 parent dc81ef3 commit a0fcfc1

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/DatabaseExporter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,14 @@ protected function buildXmlData()
302302
{
303303
if (!in_array($key, $colblob))
304304
{
305-
$buffer[] = ' <field name="' . $key . '">' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</field>';
305+
if (is_null($value))
306+
{
307+
$buffer[] = ' <field name="' . $key . '" value_is_null></field>';
308+
}
309+
else
310+
{
311+
$buffer[] = ' <field name="' . $key . '">' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</field>';
312+
}
306313
}
307314
else
308315
{

src/DatabaseImporter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,14 @@ public function importData()
267267

268268
foreach ($row->children() as $data)
269269
{
270-
$entry->{(string) $data['name']} = (string) $data;
270+
if (isset($data['value_is_null']))
271+
{
272+
$entry->{(string) $data['name']} = null;
273+
}
274+
else
275+
{
276+
$entry->{(string) $data['name']} = (string) $data;
277+
}
271278
}
272279

273280
$this->db->insertObject($tableName, $entry);

0 commit comments

Comments
 (0)