aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-11-18 14:28:21 +0000
committerMatthew Somerville <matthew@mysociety.org>2019-11-18 14:35:33 +0000
commit37bc826c8ee49d11fd56d7ec612009b57d277582 (patch)
tree8771784d40ec6a74f09d267076259f8ca01927e4
parent5b3731b263864722f26c4ab9ce28209b089a6942 (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.
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm11
2 files changed, 8 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b0492085..f85991373 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -48,6 +48,7 @@
- Fix z-index stacking bug that was causing unclickable RSS icons on /alert page. #2624
- Fix issue with inspector duplication workflow.
- Fix removal of cached photos on moderation. #2696
+ - Checking of cached front page details against database. #2696
- Development improvements:
- Upgrade the underlying framework and a number of other packages. #2473
- Add feature cobrand helper function.
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());