From f07ad307e481e2a0eb5093317367b902089384c1 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 9 Jan 2013 18:20:19 +0100 Subject: [PATCH] API Removed non-functional $join argument from DataObject::get() and other APIs See 68bb74820 --- model/DataObject.php | 31 ++++++++++++++++++++++--------- model/Versioned.php | 16 ++++++++++++++-- security/Group.php | 11 +++++++++-- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/model/DataObject.php b/model/DataObject.php index 962533bc5..7d71748f9 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -1365,8 +1365,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @param string $filter A filter to be inserted into the WHERE clause * @param string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, the static * field $default_sort on the component class will be used. - * @param string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject - * will be returned. + * @param string $join Deprecated, use leftJoin($table, $joinClause) instead * @param string|array $limit A limit expression to be inserted into the LIMIT clause * * @return HasManyList The components of the one-to-many relationship. @@ -1379,6 +1378,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity . " on class '$this->class'", E_USER_ERROR); } + if($join) { + throw new \InvalidArgumentException( + 'The $join argument has been removed. Use leftJoin($table, $joinClause) instead.' + ); + } + // If we haven't been written yet, we can't save these relations, so use a list that handles this case if(!$this->ID) { if(!isset($this->unsavedRelations[$componentName])) { @@ -1395,7 +1400,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $result = $result->forForeignID($this->ID); $result = $result->where($filter)->limit($limit)->sort($sort); - if($join) $result = $result->join($join); return $result; } @@ -1406,7 +1410,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @param string $componentName * @param string $filter * @param string|array $sort - * @param string $join + * @param string $join Deprecated, use leftJoin($table, $joinClause) instead * @param string|array $limit * @return SQLQuery */ @@ -1416,6 +1420,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity . " on class '$this->class'", E_USER_ERROR); } + if($join) { + throw new \InvalidArgumentException( + 'The $join argument has been removed. Use leftJoin($table, $joinClause) instead.' + ); + } + $joinField = $this->getRemoteJoinField($componentName, 'has_many'); $id = $this->getField("ID"); @@ -2692,8 +2702,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @param string $filter A filter to be inserted into the WHERE clause. * @param string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, * self::$default_sort will be used. - * @param string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject - * will be returned. + * @param string $join Deprecated 3.0 Join clause. Use leftJoin($table, $joinClause) instead. * @param string|array $limit A limit expression to be inserted into the LIMIT clause. * @param string $containerClass The container class to return the results in. * @@ -2717,6 +2726,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $result->setDataModel(DataModel::inst()); return $result; } + + if($join) { + throw new \InvalidArgumentException( + 'The $join argument has been removed. Use leftJoin($table, $joinClause) instead.' + ); + } $result = DataList::create($callerClass)->where($filter)->sort($sort); @@ -2727,8 +2742,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $result = $result->limit($limit); } - if($join) $result = $result->join($join); - $result->setDataModel(DataModel::inst()); return $result; } @@ -2748,7 +2761,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $list = new DataList(get_class($this)); $list->setDataModel($this->model); } else { - throw new InvalidArgumentException("DataObject::aggregate() must be called as an instance method or passed" + throw new \InvalidArgumentException("DataObject::aggregate() must be called as an instance method or passed" . " a classname"); } return $list; diff --git a/model/Versioned.php b/model/Versioned.php index 61c33dc1e..6d6b618b3 100644 --- a/model/Versioned.php +++ b/model/Versioned.php @@ -754,13 +754,25 @@ class Versioned extends DataExtension { return !$stagesAreEqual; } + /** + * @param string $filter + * @param string $sort + * @param string $limit + * @param string $join Deprecated, use leftJoin($table, $joinClause) instead + * @param string $having + */ public function Versions($filter = "", $sort = "", $limit = "", $join = "", $having = "") { return $this->allVersions($filter, $sort, $limit, $join, $having); } /** * Return a list of all the versions available. - * @param string $filter + * + * @param string $filter + * @param string $sort + * @param string $limit + * @param string $join Deprecated, use leftJoin($table, $joinClause) instead + * @param string $having */ public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "") { // Make sure the table names are not postfixed (e.g. _Live) @@ -1009,7 +1021,7 @@ class Versioned extends DataExtension { * @param string $stage The name of the stage. * @param string $filter A filter to be inserted into the WHERE clause. * @param string $sort A sort expression to be inserted into the ORDER BY clause. - * @param string $join A join expression, such as LEFT JOIN or INNER JOIN + * @param string $join Deprecated, use leftJoin($table, $joinClause) instead * @param int $limit A limit on the number of records returned from the database. * @param string $containerClass The container class for the result set (default is DataList) * @return SS_List diff --git a/security/Group.php b/security/Group.php index 837143c37..fc4e3eec6 100755 --- a/security/Group.php +++ b/security/Group.php @@ -221,7 +221,9 @@ class Group extends DataObject { * including all members which are "inherited" from children groups of this record. * See {@link DirectMembers()} for retrieving members without any inheritance. * - * @param String + * @param String $filter + * @param String $sort + * @param String $join Deprecated, use leftJoin($table, $joinClause) instead * @return ManyManyList */ public function Members($filter = "", $sort = "", $join = "", $limit = "") { @@ -231,6 +233,12 @@ class Group extends DataObject { . " DataList instead."); } + if($join) { + throw new \InvalidArgumentException( + 'The $join argument has been removed. Use leftJoin($table, $joinClause) instead.' + ); + } + // First get direct members as a base result $result = $this->DirectMembers(); // Remove the default foreign key filter in prep for re-applying a filter containing all children groups. @@ -242,7 +250,6 @@ class Group extends DataObject { // Now set all children groups as a new foreign key $groups = Group::get()->byIDs($this->collateFamilyIDs()); $result = $result->forForeignID($groups->column('ID'))->where($filter)->sort($sort)->limit($limit); - if($join) $result = $result->join($join); return $result; }