diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-05 14:33:35 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-06 17:24:12 +0000 |
commit | fbca1099ba2b83d0f0bedf19d953a50282cc7c21 (patch) | |
tree | e963a2c3c6f73a6b7864fdb849a3ff7e02bb3fc0 /perllib/FixMyStreet/App/Controller/Admin.pm | |
parent | e9dfb010c6ad7fdde8dd897455f7cbffde0d9de6 (diff) |
Remove category_options_copy.
This variable existed to keep a copy of the categories before it was
overwritten by report_edit_location (if a bad location was provided)
calling the variable setup functions again. But really, the function
shouldn't be overwriting the stash, it's only testing the lookup and
so should restore the stash at its end.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 253840082..795a7a3d8 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -1008,11 +1008,18 @@ sub report_edit_location : Private { my ($lat, $lon) = map { Utils::truncate_coordinate($_) } $problem->latitude, $problem->longitude; if ( $c->stash->{latitude} != $lat || $c->stash->{longitude} != $lon ) { + # The two actions below change the stash, setting things up for e.g. a + # new report. But here we're only doing it in order to check the found + # bodies match; we don't want to overwrite the existing report data if + # this lookup is bad. So let's save the stash and restore it after the + # comparison. + my $safe_stash = { %{$c->stash} }; $c->forward('/council/load_and_check_areas', []); $c->forward('/report/new/setup_categories_and_bodies'); my %allowed_bodies = map { $_ => 1 } @{$problem->bodies_str_ids}; my @new_bodies = @{$c->stash->{bodies_to_list}}; my $bodies_match = grep { exists( $allowed_bodies{$_} ) } @new_bodies; + $c->stash($safe_stash); return unless $bodies_match; $problem->latitude($c->stash->{latitude}); $problem->longitude($c->stash->{longitude}); @@ -1035,7 +1042,6 @@ sub categories_for_point : Private { # Remove the "Pick a category" option shift @{$c->stash->{category_options}} if @{$c->stash->{category_options}}; - $c->stash->{category_options_copy} = $c->stash->{category_options}; $c->stash->{categories_hash} = { map { $_->{name} => 1 } @{$c->stash->{category_options}} }; } |