Issue 9281: User export now exports data
This commit is contained in:
parent
31630099ff
commit
4ba42bc06a
1 changed files with 11 additions and 9 deletions
|
@ -27,6 +27,7 @@ use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBStructure;
|
use Friendica\Database\DBStructure;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Item;
|
||||||
use Friendica\Module\BaseSettings;
|
use Friendica\Module\BaseSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,10 +116,13 @@ class UserExport extends BaseSettings
|
||||||
while ($row = DBA::fetch($rows)) {
|
while ($row = DBA::fetch($rows)) {
|
||||||
$p = [];
|
$p = [];
|
||||||
foreach ($dbStructure[$table]['fields'] as $column => $field) {
|
foreach ($dbStructure[$table]['fields'] as $column => $field) {
|
||||||
|
if (!isset($row[$column])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($field['type'] == 'datetime') {
|
if ($field['type'] == 'datetime') {
|
||||||
$p[$column] = $v ?? DBA::NULL_DATETIME;
|
$p[$column] = $row[$column] ?? DBA::NULL_DATETIME;
|
||||||
} else {
|
} else {
|
||||||
$p[$column] = $v;
|
$p[$column] = $row[$column];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result[] = $p;
|
$result[] = $p;
|
||||||
|
@ -140,6 +144,9 @@ class UserExport extends BaseSettings
|
||||||
|
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
foreach ($rr as $k => $v) {
|
foreach ($rr as $k => $v) {
|
||||||
|
if (empty($dbStructure[$table]['fields'][$k])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch ($dbStructure[$table]['fields'][$k]['type']) {
|
switch ($dbStructure[$table]['fields'][$k]['type']) {
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
$result[$k] = $v ?? DBA::NULL_DATETIME;
|
$result[$k] = $v ?? DBA::NULL_DATETIME;
|
||||||
|
@ -238,13 +245,8 @@ class UserExport extends BaseSettings
|
||||||
// chunk the output to avoid exhausting memory
|
// chunk the output to avoid exhausting memory
|
||||||
|
|
||||||
for ($x = 0; $x < $total; $x += 500) {
|
for ($x = 0; $x < $total; $x += 500) {
|
||||||
$r = q("SELECT * FROM `item` WHERE `uid` = %d LIMIT %d, %d",
|
$items = Item::selectToArray(Item::ITEM_FIELDLIST, ['uid' => local_user()], ['limit' => [$x, 500]]);
|
||||||
intval(local_user()),
|
$output = ['item' => $items];
|
||||||
intval($x),
|
|
||||||
intval(500)
|
|
||||||
);
|
|
||||||
|
|
||||||
$output = ['item' => $r];
|
|
||||||
echo json_encode($output, JSON_PARTIAL_OUTPUT_ON_ERROR). "\n";
|
echo json_encode($output, JSON_PARTIAL_OUTPUT_ON_ERROR). "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue