diff options
author | Dave Arter <davea@mysociety.org> | 2018-03-15 10:57:31 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-03-15 11:19:41 +0000 |
commit | e1f7ee00b13ca71a2d2197b32dae73d8f703ba6c (patch) | |
tree | cc22f277894d7c935acc035c04665277e1f94f22 /perllib/FixMyStreet/App/Controller/Report.pm | |
parent | 40a3bfb7566b02db2eb6019adcbefeaa19ffb42f (diff) |
Fix JSON-encoding crash on /report/ajax
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 7062f481f..df4dc5f77 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -221,9 +221,15 @@ sub format_problem_for_display : Private { if ( $c->stash->{ajax} ) { $c->res->content_type('application/json; charset=utf-8'); + + # encode_json doesn't like DateTime objects, so strip them out + my $report_hashref = $c->cobrand->problem_as_hashref( $problem, $c ); + delete $report_hashref->{created}; + delete $report_hashref->{confirmed}; + my $content = encode_json( { - report => $c->cobrand->problem_as_hashref( $problem, $c ), + report => $report_hashref, updates => $c->cobrand->updates_as_hashref( $problem, $c ), } ); |