diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-11-18 14:28:21 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-11-18 14:35:33 +0000 |
commit | 37bc826c8ee49d11fd56d7ec612009b57d277582 (patch) | |
tree | 8771784d40ec6a74f09d267076259f8ca01927e4 /perllib/FixMyStreet/DB/ResultSet/Problem.pm | |
parent | 5b3731b263864722f26c4ab9ce28209b089a6942 (diff) |
Recheck cached front page details against database
It was only checking the cached details, so not spotting if
a report had been hidden in the time since being cached.
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Problem.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 72a9852fc..996e990a8 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -155,10 +155,13 @@ sub _recent { } else { $probs = Memcached::get($key); if ($probs) { - # Need to reattach schema so that confirmed column gets reinflated. - $probs->[0]->result_source->schema( $rs->result_source->schema ) if $probs->[0]; - # Catch any cached ones since hidden - $probs = [ grep { $_->photo && ! $_->is_hidden && !$_->non_public } @$probs ]; + # Need to refetch to check if hidden since cached + $probs = [ $rs->search({ + id => [ map { $_->id } @$probs ], + photo => { '!=', undef }, + non_public => 'f', + state => [ FixMyStreet::DB::Result::Problem->visible_states() ], + })->all ]; } else { $probs = [ $rs->search( $query, $attrs )->all ]; Memcached::set($key, $probs, _cache_timeout()); |