From bb14045626a6a2ba1b6d0ac49a13b8dacfd00ece Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 16 Dec 2009 05:43:54 +0000 Subject: [PATCH] BUGFIX Fixed ModelAsController::findOldPage() failing on MSSQLDatabase using "sqlsrv" driver (from r94885) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95628 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/control/ModelAsController.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/control/ModelAsController.php b/core/control/ModelAsController.php index be54ff583..c7d6c4485 100755 --- a/core/control/ModelAsController.php +++ b/core/control/ModelAsController.php @@ -131,14 +131,13 @@ class ModelAsController extends Controller implements NestedController { 1 ); - if(($result = $query->execute()) && $result->numRecords()) { - $recordID = $result->column(); - - if($oldPage = DataObject::get_by_id('SiteTree', $recordID[0])) { - // Run the page through an extra filter to ensure that all decorators are applied. - if(SiteTree::get_by_link($oldPage->RelativeLink())) return $oldPage; - } + $record = $query->execute()->first(); + if(!$record) return false; + + if($oldPage = DataObject::get_by_id('SiteTree', $record['RecordID'])) { + // Run the page through an extra filter to ensure that all decorators are applied. + if(SiteTree::get_by_link($oldPage->RelativeLink())) return $oldPage; } } -} +} \ No newline at end of file