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