Correctly output commas for JSON backups

This commit is contained in:
Evan Prodromou 2013-05-29 16:45:52 -04:00
parent 4f818c5c81
commit 2f5cdbb9c1

View File

@ -101,6 +101,8 @@ class UserActivityStream extends AtomUserNoticeFeed
*/ */
function renderEntries($format=Feed::ATOM, $handle=null) function renderEntries($format=Feed::ATOM, $handle=null)
{ {
$haveOne = false;
$end = time() + 1; $end = time() + 1;
foreach ($this->objs as $obj) { foreach ($this->objs as $obj) {
try { try {
@ -123,7 +125,11 @@ class UserActivityStream extends AtomUserNoticeFeed
if ($format == Feed::ATOM) { if ($format == Feed::ATOM) {
$nact->outputTo($this, false, false); $nact->outputTo($this, false, false);
} else { } else {
if ($haveOne) {
fwrite($handle, ",");
}
fwrite($handle, json_encode($nact->asArray())); fwrite($handle, json_encode($nact->asArray()));
$haveOne = true;
} }
} catch (Exception $e) { } catch (Exception $e) {
common_log(LOG_ERR, $e->getMessage()); common_log(LOG_ERR, $e->getMessage());
@ -145,7 +151,11 @@ class UserActivityStream extends AtomUserNoticeFeed
// Only show the author sub-element if it's different from default user // Only show the author sub-element if it's different from default user
$act->outputTo($this, false, ($act->actor->id != $this->user->uri)); $act->outputTo($this, false, ($act->actor->id != $this->user->uri));
} else { } else {
if ($haveOne) {
fwrite($handle, ",");
}
fwrite($handle, json_encode($act->asArray())); fwrite($handle, json_encode($act->asArray()));
$haveOne = true;
} }
} catch (Exception $e) { } catch (Exception $e) {
common_log(LOG_ERR, $e->getMessage()); common_log(LOG_ERR, $e->getMessage());
@ -167,7 +177,11 @@ class UserActivityStream extends AtomUserNoticeFeed
if ($format == Feed::ATOM) { if ($format == Feed::ATOM) {
$nact->outputTo($this, false, false); $nact->outputTo($this, false, false);
} else { } else {
if ($haveOne) {
fwrite($handle, ",");
}
fwrite($handle, json_encode($nact->asArray())); fwrite($handle, json_encode($nact->asArray()));
$haveOne = true;
} }
} catch (Exception $e) { } catch (Exception $e) {
common_log(LOG_ERR, $e->getMessage()); common_log(LOG_ERR, $e->getMessage());