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
1821ccbb7d
commit
9398fcaaa1
@ -31,17 +31,23 @@ class SiteTreeFileExtension extends DataExtension {
|
||||
* Updates link tracking.
|
||||
*/
|
||||
function onAfterDelete() {
|
||||
$brokenPages = $this->owner->BackLinkTracking();
|
||||
if($brokenPages) {
|
||||
// We query the explicit ID list, because BackLinkTracking will get modified after the stage
|
||||
// site does its thing
|
||||
$brokenPageIDs = $this->owner->BackLinkTracking()->column("ID");
|
||||
if($brokenPageIDs) {
|
||||
$origStage = Versioned::current_stage();
|
||||
|
||||
// This will syncLinkTracking on draft
|
||||
Versioned::reading_stage('Stage');
|
||||
$brokenPages = DataObject::get('SiteTree')->byIDs($brokenPageIDs);
|
||||
foreach($brokenPages as $brokenPage) $brokenPage->write();
|
||||
|
||||
// This will syncLinkTracking on published
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user