diff --git a/src/Versioned.php b/src/Versioned.php index ac1c9194..4ae6f237 100644 --- a/src/Versioned.php +++ b/src/Versioned.php @@ -10,6 +10,7 @@ use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Config\Config; +use SilverStripe\Core\Convert; use SilverStripe\Core\Extension; use SilverStripe\Core\Resettable; use SilverStripe\Dev\Deprecation; @@ -629,33 +630,23 @@ protected function augmentSQLVersionedArchive(SQLSelect $query, DataQuery $dataQ $stageColumn = $stage === static::LIVE ? 'WasPublished' : 'WasDraft'; - $stageCondition = "AND \"{$baseTable}_Versions\".\"{$stageColumn}\" = 1"; + $stageCondition = "AND \"{$baseTable}_Versions_Latest\".\"{$stageColumn}\" = 1"; } else { $stageCondition = ''; } - // Join on latest version filtered by date - $query->addInnerJoin( - <<addWhere(["\"{$baseTable}_Versions\".\"Version\"" => $latestVersionSql]); } /**