mirror of
https://github.com/silverstripe/silverstripe-externallinks.git
synced 2024-10-22 15:05:44 +00:00
BUG: Fixing report page link and set to check stage not live
This commit is contained in:
parent
5a1c636264
commit
da7e45ddd4
@ -60,6 +60,7 @@ class BrokenExternalLinksReport extends SS_Report {
|
||||
$links = BrokenExternalLink::get();
|
||||
foreach ($links as $link) {
|
||||
$link->PageLink = $link->Page()->Title;
|
||||
$link->ID = $link->Page()->ID;
|
||||
$returnSet->push($link);
|
||||
}
|
||||
return $returnSet;
|
||||
|
@ -32,7 +32,7 @@ class CheckExternalLinks extends BuildTask {
|
||||
'TrackID' => $track->ID,
|
||||
'Processed' => 0
|
||||
))->limit($limit)->column('PageID');
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Live')
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Stage')
|
||||
->filter('ID', $batch)
|
||||
->limit($limit);
|
||||
$this->updateJobInfo('Fetching pages to check');
|
||||
@ -43,7 +43,7 @@ class CheckExternalLinks extends BuildTask {
|
||||
}
|
||||
// if the script is to be started
|
||||
} else {
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Live')->column('ID');
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Stage')->column('ID');
|
||||
$noPages = count($pages);
|
||||
|
||||
$track = BrokenExternalPageTrackStatus::create();
|
||||
@ -63,7 +63,7 @@ class CheckExternalLinks extends BuildTask {
|
||||
'TrackID' => $track->ID
|
||||
))->limit($limit)->column('PageID');
|
||||
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Live')
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Stage')
|
||||
->filter('ID', $batch);
|
||||
}
|
||||
$trackID = $track->ID;
|
||||
@ -139,7 +139,7 @@ class CheckExternalLinks extends BuildTask {
|
||||
|
||||
// bypass the ORM as syncLinkTracking does not allow you
|
||||
// to update HasBrokenLink to true
|
||||
$query = "UPDATE \"SiteTree_Live\" SET \"HasBrokenLink\" = 1 ";
|
||||
$query = "UPDATE \"SiteTree\" SET \"HasBrokenLink\" = 1 ";
|
||||
$query .= "WHERE \"ID\" = " . (int)$page->ID;
|
||||
$result = DB::query($query);
|
||||
if (!$result) {
|
||||
|
@ -7,17 +7,18 @@ class ExternalLinks extends FunctionalTest {
|
||||
public function testLinks() {
|
||||
// uses http://127.0.0.1 to test a working link
|
||||
$working = $this->objFromFixture('SiteTree', 'working');
|
||||
$working->publish('Stage', 'Live');
|
||||
$working->publish('Stage', 'Stage');
|
||||
$task = new CheckExternalLinks();
|
||||
$task->run(null);
|
||||
$brokenLinks = BrokenExternalLink::get();
|
||||
$this->assertEquals(0, $brokenLinks->count());
|
||||
$brokenLinks = BrokenExternalLink::get()->column('Link');;
|
||||
// confirm the working link has not been added as a broken link
|
||||
$this->assertNotEquals($working->Link, $brokenLinks[0]);
|
||||
}
|
||||
|
||||
public function testBrokenLink() {
|
||||
// uses http://192.0.2.1 for a broken link
|
||||
$broken = $this->objFromFixture('SiteTree', 'broken');
|
||||
$broken->publish('Stage', 'Live');
|
||||
$broken->publish('Stage', 'Stage');
|
||||
$task = new CheckExternalLinks();
|
||||
$task->run(null);
|
||||
$brokenLinks = BrokenExternalLink::get();
|
||||
|
Loading…
x
Reference in New Issue
Block a user