From 2fee654bb6b839a848fecf1985c19efa338f7f45 Mon Sep 17 00:00:00 2001 From: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Wed, 26 May 2021 12:18:17 +1200 Subject: [PATCH] FIX: Optimise PagesWithoutReviewScheduleReport database query Drastically speeds up report generation on very large sites and reduces the likelyhood of running into memory issues. --- src/Reports/PagesWithoutReviewScheduleReport.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Reports/PagesWithoutReviewScheduleReport.php b/src/Reports/PagesWithoutReviewScheduleReport.php index 0f7b402..e658a2d 100644 --- a/src/Reports/PagesWithoutReviewScheduleReport.php +++ b/src/Reports/PagesWithoutReviewScheduleReport.php @@ -111,7 +111,7 @@ class PagesWithoutReviewScheduleReport extends Report { Versioned::set_stage(Versioned::DRAFT); - $records = SiteTree::get(); + $records = SiteTree::get()->filter('NextReviewDate', null); $compatibility = ContentReviewCompatability::start(); // If there's no review dates set, default to all pages due for review now. @@ -148,10 +148,6 @@ class PagesWithoutReviewScheduleReport extends Report */ protected function hasReviewSchedule(DataObject $record) { - if (!$record->obj("NextReviewDate")->exists()) { - return false; - } - $options = $record->getOptions(); if ($options && $options->OwnerGroups()->count() == 0 && $options->OwnerUsers()->count() == 0) {