Merge branch '4.13' into 4

This commit is contained in:
github-actions 2023-08-19 13:23:54 +00:00
commit 01d389ec44

View File

@ -116,15 +116,22 @@ class SiteTreeLinkTracking extends DataExtension
$allFields = DataObject::getSchema()->fieldSpecs($this->owner); $allFields = DataObject::getSchema()->fieldSpecs($this->owner);
$linkedPages = []; $linkedPages = [];
$anyBroken = false; $anyBroken = false;
$hasTrackedFields = false;
foreach ($allFields as $field => $fieldSpec) { foreach ($allFields as $field => $fieldSpec) {
$fieldObj = $this->owner->dbObject($field); $fieldObj = $this->owner->dbObject($field);
if ($fieldObj instanceof DBHTMLText) { if ($fieldObj instanceof DBHTMLText) {
$hasTrackedFields = true;
// Merge links in this field with global list. // Merge links in this field with global list.
$linksInField = $this->trackLinksInField($field, $anyBroken); $linksInField = $this->trackLinksInField($field, $anyBroken);
$linkedPages = array_merge($linkedPages, $linksInField); $linkedPages = array_merge($linkedPages, $linksInField);
} }
} }
// We need a boolean flag instead of checking linkedPages because it can be empty when pages are removed
if (!$hasTrackedFields) {
return;
}
// Soft support for HasBrokenLink db field (e.g. SiteTree) // Soft support for HasBrokenLink db field (e.g. SiteTree)
if ($this->owner->hasField('HasBrokenLink')) { if ($this->owner->hasField('HasBrokenLink')) {
$this->owner->HasBrokenLink = $anyBroken; $this->owner->HasBrokenLink = $anyBroken;