Merge #16346 - Export Blobs as hex on JSON export

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2020-11-12 22:15:19 +01:00
commit 5eb06e68e2
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889

View File

@ -20,6 +20,7 @@ use function bin2hex;
use function explode; use function explode;
use function json_encode; use function json_encode;
use function stripslashes; use function stripslashes;
use function strpos;
/** /**
* Handles the export for the JSON format * Handles the export for the JSON format
@ -268,8 +269,8 @@ class ExportJson extends ExportPlugin
$data = []; $data = [];
for ($i = 0; $i < $columns_cnt; $i++) { for ($i = 0; $i < $columns_cnt; $i++) {
if ($fieldsMeta[$i]->type === 'geometry') { if ($fieldsMeta[$i]->type === 'geometry' || strpos($fieldsMeta[$i]->type, 'blob') !== false) {
// export GIS types as hex // export GIS and blob types as hex
$record[$i] = '0x' . bin2hex($record[$i]); $record[$i] = '0x' . bin2hex($record[$i]);
} }
$data[$columns[$i]] = $record[$i]; $data[$columns[$i]] = $record[$i];