From bec5adf09b733904a4e8d0aa55bdc337489af533 Mon Sep 17 00:00:00 2001 From: Jonathon Menz Date: Fri, 21 Oct 2016 19:33:32 -0700 Subject: [PATCH] FIX Versioned sort by ID Prevent SQL error from a Versioned DataObject with e.g. $default_sort = 'ID DESC' --- model/Versioned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/Versioned.php b/model/Versioned.php index af1648b65..6ab3a25a4 100644 --- a/model/Versioned.php +++ b/model/Versioned.php @@ -313,7 +313,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider { // Ensure that any sort order referring to this ID is correctly aliased $orders = $query->getOrderBy(); foreach($orders as $order => $dir) { - if($order === "\"$baseTable\".\"ID\"") { + if($order === "\"$baseTable\".\"ID\"" || trim($order, "'\"") === "ID") { unset($orders[$order]); $orders["\"{$baseTable}_versions\".\"RecordID\""] = $dir; }