diff --git a/code/model/BrokenExternalLink.php b/code/model/BrokenExternalLink.php index a716aea..24ff85f 100644 --- a/code/model/BrokenExternalLink.php +++ b/code/model/BrokenExternalLink.php @@ -8,7 +8,8 @@ class BrokenExternalLink extends DataObject { ); private static $has_one = array( - 'Page' => 'Page' + 'Page' => 'Page', + 'Track' => 'BrokenExternalLink' ); public static $summary_fields = array( diff --git a/code/reports/BrokenExternalLinksReport.php b/code/reports/BrokenExternalLinksReport.php index 34bfbec..c908820 100644 --- a/code/reports/BrokenExternalLinksReport.php +++ b/code/reports/BrokenExternalLinksReport.php @@ -34,7 +34,8 @@ class BrokenExternalLinksReport extends SS_Report { * @return string */ public function title() { - return _t('ExternalBrokenLinksReport.EXTERNALBROKENLINKS',"External broken links report"); + return _t('ExternalBrokenLinksReport.EXTERNALBROKENLINKS', + "External broken links report"); } /** @@ -56,8 +57,14 @@ class BrokenExternalLinksReport extends SS_Report { } public function sourceRecords() { + $track = CheckExternalLinks::getLatestTrack(); $returnSet = new ArrayList(); - $links = BrokenExternalLink::get(); + if ($track && $track->exists()) { + $links = BrokenExternalLink::get() + ->filter('TrackID', $track->ID); + } else { + $links = BrokenExternalLink::get(); + } foreach ($links as $link) { $link->PageLink = $link->Page()->Title; $link->ID = $link->Page()->ID; diff --git a/code/tasks/CheckExternalLinks.php b/code/tasks/CheckExternalLinks.php index 7d4a605..4fa8dce 100644 --- a/code/tasks/CheckExternalLinks.php +++ b/code/tasks/CheckExternalLinks.php @@ -124,6 +124,7 @@ class CheckExternalLinks extends BuildTask { $brokenLink->PageID = $page->ID; $brokenLink->Link = $href; $brokenLink->HTTPCode = $httpCode; + $brokenLink->TrackID = $track->ID; $brokenLink->write(); // set the broken link class