From 2cb67efe074263253baefa204c77896ad7d9aec7 Mon Sep 17 00:00:00 2001 From: Stig Lindqvist Date: Fri, 9 Mar 2012 15:15:55 +1300 Subject: [PATCH] API CHANGE DataObject::getComponents() should use default value for limit as NULL --- model/DataList.php | 5 ++++- model/DataObject.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/model/DataList.php b/model/DataList.php index 92af851e1..1984af0df 100644 --- a/model/DataList.php +++ b/model/DataList.php @@ -146,7 +146,10 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab * @param string $limit */ public function limit($limit, $offset = 0) { - if(!is_numeric($limit)) { + if(!$limit && !$offset) { + return $this; + } + if($limit && !is_numeric($limit)) { Deprecation::notice('3.0', 'Please pass limits as 2 arguments, rather than an array or SQL fragment.'); } $this->dataQuery->limit($limit, $offset); diff --git a/model/DataObject.php b/model/DataObject.php index ca972f6b2..f11ae58e2 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -1309,7 +1309,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * * @return HasManyList The components of the one-to-many relationship. */ - public function getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = "") { + public function getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = null) { $result = null; if(!$componentClass = $this->has_many($componentName)) {