Closed lekoala closed 10 months ago
Recently found this by chance
It seems that since FileLinkTracking is attached to the dataobject, it runs for classes that are not relevant (eg: LoginSession)
By checking if there are actually any DBHTMLText, the query is not happening anymore
// Build a list of HTMLText fields, merging all linked pages together. $allFields = DataObject::getSchema()->fieldSpecs($this->owner); $linkedPages = []; $anyBroken = false; $hasTrackedFields = false; foreach ($allFields as $field => $fieldSpec) { $fieldObj = $this->owner->dbObject($field); if ($fieldObj instanceof DBHTMLText) { $hasTrackedFields = true; // Merge links in this field with global list. $linksInField = $this->trackLinksInField($field, $anyBroken); $linkedPages = array_merge($linkedPages, $linksInField); } } if (!$hasTrackedFields) { return; }
same thing for SiteTreeLinkTracking
maybe i'm missing something, but these changes seem to save two queries :-)
Both PRs are merged. Thanks for that.
Recently found this by chance
It seems that since FileLinkTracking is attached to the dataobject, it runs for classes that are not relevant (eg: LoginSession)
By checking if there are actually any DBHTMLText, the query is not happening anymore
PRs