diff --git a/src/Versioned.php b/src/Versioned.php index 087fc298..e96f1345 100644 --- a/src/Versioned.php +++ b/src/Versioned.php @@ -19,6 +19,7 @@ use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataQuery; +use SilverStripe\ORM\DataQuery_SubGroup; use SilverStripe\ORM\DB; use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\Queries\SQLSelect; @@ -655,6 +656,9 @@ protected function prepareMaxVersionSubSelect(SQLSelect $baseQuery, DataQuery $d // We can ONLY promote a filter on the primary key of the base table. Any other conditions will make the // version returned incorrect, as we are filtering out version that may be the latest (and correct) version foreach ($baseQuery->getWhere() as $condition) { + if (is_object($condition)) { + continue; + } $conditionClause = key($condition); // Pull out the table and field for this condition. We'll skip anything we can't parse if (preg_match('/^"([^"]+)"\."([^"]+)"/', $conditionClause, $matches) !== 1) {