From 788b435821056913ac7f474a75598f59ca112372 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 10 Aug 2009 04:36:17 +0000 Subject: [PATCH] BUGFIX: Fixed SQLQuery::filtersOnID() for cases where a ClassName filter is inserted before the ID filter. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84093 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SQLQuery.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/model/SQLQuery.php b/core/model/SQLQuery.php index c959b1eda..0b7aa4480 100755 --- a/core/model/SQLQuery.php +++ b/core/model/SQLQuery.php @@ -392,11 +392,13 @@ class SQLQuery extends Object { * @return boolean */ function filtersOnID() { - return ( - $this->where - //&& count($this->where) == 1 - && preg_match('/^(.*\.)?("|`)?ID("|`)?\s?=/', $this->where[0]) - ); + $regexp = '/^(.*\.)?("|`)?ID("|`)?\s?=/'; + + // Sometimes the ID filter will be the 2nd element, if there's a ClasssName filter first. + if(isset($this->where[0]) && preg_match($regexp, $this->where[0])) return true; + if(isset($this->where[1]) && preg_match($regexp, $this->where[1])) return true; + + return false; } /**