mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUGFIX: Fix SiteTree broken link correction to handle the fact that relations aren't cached.
This commit is contained in:
parent
a04ac5ebbe
commit
509d32e58f
@ -31,17 +31,23 @@ class SiteTreeFileExtension extends DataExtension {
|
|||||||
* Updates link tracking.
|
* Updates link tracking.
|
||||||
*/
|
*/
|
||||||
function onAfterDelete() {
|
function onAfterDelete() {
|
||||||
$brokenPages = $this->owner->BackLinkTracking();
|
// We query the explicit ID list, because BackLinkTracking will get modified after the stage
|
||||||
if($brokenPages) {
|
// site does its thing
|
||||||
|
$brokenPageIDs = $this->owner->BackLinkTracking()->column("ID");
|
||||||
|
if($brokenPageIDs) {
|
||||||
$origStage = Versioned::current_stage();
|
$origStage = Versioned::current_stage();
|
||||||
|
|
||||||
// This will syncLinkTracking on draft
|
// This will syncLinkTracking on draft
|
||||||
Versioned::reading_stage('Stage');
|
Versioned::reading_stage('Stage');
|
||||||
|
$brokenPages = DataObject::get('SiteTree')->byIDs($brokenPageIDs);
|
||||||
foreach($brokenPages as $brokenPage) $brokenPage->write();
|
foreach($brokenPages as $brokenPage) $brokenPage->write();
|
||||||
|
|
||||||
// This will syncLinkTracking on published
|
// This will syncLinkTracking on published
|
||||||
Versioned::reading_stage('Live');
|
Versioned::reading_stage('Live');
|
||||||
foreach($brokenPages as $brokenPage) $brokenPage->write();
|
$liveBrokenPages = DataObject::get('SiteTree')->byIDs($brokenPageIDs);
|
||||||
|
foreach($liveBrokenPages as $brokenPage) {
|
||||||
|
$brokenPage->write();
|
||||||
|
}
|
||||||
|
|
||||||
Versioned::reading_stage($origStage);
|
Versioned::reading_stage($origStage);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user