Skip to content

Commit

Permalink
Merge branch '6.0' into 6
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 12, 2025
2 parents 7e96a9c + 0f5de9b commit 305700c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions code/Reports/BrokenLinksReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public function title()
public function sourceRecords($params, $sort, $limit)
{
$sitetreeTbl = DataObject::singleton(SiteTree::class)->baseTable();
$schema = DataObject::getSchema();

$join = '';
$joinArgs = [];
$sortBrokenReason = false;
if ($sort) {
$parts = explode(' ', $sort ?? '');
Expand All @@ -41,12 +42,11 @@ public function sourceRecords($params, $sort, $limit)
$sort = 'URLSegment ' . $direction;
} elseif ($field == 'Subsite.Title') {
$subSiteTbl = DataObject::singleton(Subsite::class)->baseTable();
$join = sprintf(
'LEFT JOIN "%s" ON "%s"."ID" = "%s"."SubsiteID"',
$joinArgs = [
$subSiteTbl,
$subSiteTbl,
$sitetreeTbl
);
$schema->sqlColumnForField(Subsite::class, 'ID')
. ' = ' . $schema->sqlColumnForField(SiteTree::class, 'SubsiteID')
];
} elseif ($field == 'BrokenReason') {
$sortBrokenReason = true;
$sort = '';
Expand All @@ -57,9 +57,12 @@ public function sourceRecords($params, $sort, $limit)
];
$isLive = !isset($params['CheckSite']) || $params['CheckSite'] === 'Published';
if ($isLive) {
$ret = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE, $brokenFilter, $sort, $join, $limit);
$ret = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE, $brokenFilter, $sort, $limit);
} else {
$ret = DataObject::get(SiteTree::class, $brokenFilter, $sort, $join, $limit);
$ret = DataObject::get(SiteTree::class, $brokenFilter, $sort, $limit);
}
if (!empty($joinArgs)) {
$ret->leftJoin(...$joinArgs);
}

$returnSet = ArrayList::create();
Expand Down

0 comments on commit 305700c

Please sign in to comment.