Correctly output commas for JSON backups

This commit is contained in:
Evan Prodromou 2013-05-29 16:45:52 -04:00
parent 1c1bcd7cc6
commit a9f4575d31
1 changed files with 14 additions and 0 deletions

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());