mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-06-26 14:39:27 +02:00
Merge pull request #1052 from @dmeeking
This commit is contained in:
commit
4aca9ac145
|
@ -55,26 +55,20 @@ class OldPageRedirector extends Extension {
|
|||
}
|
||||
|
||||
if (!$page) {
|
||||
// If we haven't found a candidate, lets resort to finding an old page with this URL segment
|
||||
$oldFilter = array(
|
||||
'"SiteTree_versions"."URLSegment"' => $URL,
|
||||
'"SiteTree_versions"."WasPublished"' => true
|
||||
);
|
||||
if($parent) {
|
||||
$oldFilter[] = array('"SiteTree_versions"."ParentID"' => $parent->ID);
|
||||
}
|
||||
$query = new SQLSelect(
|
||||
'"RecordID"',
|
||||
'"SiteTree_versions"',
|
||||
$oldFilter,
|
||||
'"LastEdited" DESC',
|
||||
null,
|
||||
null,
|
||||
1
|
||||
);
|
||||
$record = $query->execute()->first();
|
||||
if ($record) {
|
||||
$page = SiteTree::get()->byID($record['RecordID']);
|
||||
// If we haven't found a candidate, resort to finding a previously published page version with this URL segment
|
||||
$oldRecords = DataList::create('SiteTree')
|
||||
->filter(array(
|
||||
'URLSegment' => $URL,
|
||||
'WasPublished' => 1
|
||||
))
|
||||
->sort('"LastEdited" DESC')
|
||||
->setDataQueryParam("Versioned.mode", 'all_versions');
|
||||
|
||||
if($parent) $oldRecords->filter(array('ParentID' => $parent->ID));
|
||||
|
||||
$page = $oldRecords->first();
|
||||
|
||||
if ($page) {
|
||||
$redirect = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user