mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Revert BackLinkTracking to return Parent Object of the SiteTreeLink rather than SiteTreeLink itself
This commit is contained in:
parent
0bff8728b1
commit
b138eb06ff
@ -1734,27 +1734,32 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
// @todo - Implement PolymorphicManyManyList to replace this
|
// @todo - Implement PolymorphicManyManyList to replace this
|
||||||
$list = ArrayList::create();
|
$list = ArrayList::create();
|
||||||
|
|
||||||
$joinClause = sprintf(
|
$siteTreelinkTable = SiteTreeLink::singleton()->baseTable();
|
||||||
"\"%s\".\"ParentID\"=\"ParentRelationTable\".\"ID\"",
|
|
||||||
SiteTreeLink::singleton()->baseTable()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get the list of back links classes
|
// Get the list of back links classes
|
||||||
$linkClasses = $this->BackLinks()->exclude(['ParentClass' => null])->columnUnique('ParentClass');
|
$parentClasses = $this->BackLinks()->exclude(['ParentClass' => null])->columnUnique('ParentClass');
|
||||||
|
|
||||||
// Get list of sitreTreelink and join them to the their parent class to make sure we don't get orphan records.
|
// Get list of sitreTreelink and join them to the their parent class to make sure we don't get orphan records.
|
||||||
foreach ($linkClasses as $linkClass) {
|
foreach ($parentClasses as $parentClass) {
|
||||||
$links = $this->BackLinks()
|
$joinClause = sprintf(
|
||||||
->filter(['ParentClass' => $linkClass])
|
"\"%s\".\"ParentID\"=\"%s\".\"ID\"",
|
||||||
|
$siteTreelinkTable,
|
||||||
|
$linkTable,
|
||||||
|
DataObject::singleton($parentClass)->baseTable()
|
||||||
|
);
|
||||||
|
|
||||||
|
$links = DataObject::get($parentClass)
|
||||||
->innerJoin(
|
->innerJoin(
|
||||||
DataObject::singleton($linkClass)->baseTable(),
|
$siteTreelinkTable,
|
||||||
$joinClause,
|
$joinClause
|
||||||
'ParentRelationTable'
|
|
||||||
)
|
)
|
||||||
|
->where([
|
||||||
|
"\"$siteTreelinkTable\".\"LinkedID\"" => $this->ID,
|
||||||
|
"\"$siteTreelinkTable\".\"ParentClass\"" => $parentClass,
|
||||||
|
])
|
||||||
->alterDataQuery(function ($query) {
|
->alterDataQuery(function ($query) {
|
||||||
$query->selectField("'Content link'", "DependentLinkType");
|
$query->selectField("'Content link'", "DependentLinkType");
|
||||||
})
|
});
|
||||||
;
|
|
||||||
$list->merge($links);
|
$list->merge($links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user