From 40d12b85c4913820deed517ad78a54d7ed1899f8 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 20 Aug 2020 09:30:50 -0400 Subject: [PATCH] Loop on expected fields instead of existing fields in Settings\UserExport - We don't delete fields, so there can be more fields in the database than in the DB structure - Address https://github.com/friendica/friendica/issues/8877#issuecomment-663875895 --- src/Module/Settings/UserExport.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Module/Settings/UserExport.php b/src/Module/Settings/UserExport.php index 0eaa72ffe..132505371 100644 --- a/src/Module/Settings/UserExport.php +++ b/src/Module/Settings/UserExport.php @@ -114,14 +114,11 @@ class UserExport extends BaseSettings $rows = DBA::p($query); while ($row = DBA::fetch($rows)) { $p = []; - foreach ($row as $k => $v) { - switch ($dbStructure[$table]['fields'][$k]['type']) { - case 'datetime': - $p[$k] = $v ?? DBA::NULL_DATETIME; - break; - default: - $p[$k] = $v; - break; + foreach ($dbStructure[$table]['fields'] as $column => $field) { + if ($field['type'] == 'datetime') { + $p[$column] = $v ?? DBA::NULL_DATETIME; + } else { + $p[$column] = $v; } } $result[] = $p;