From 4c0105a3c4e7f7aa556dd0d02abc641b61fb8f3b Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Fri, 28 Oct 2011 14:36:20 +1300 Subject: [PATCH] MINOR: Fix deprecated notices - change old references to 2.5 from ORM work to 3.0.0, and use new deprecation notice system --- forms/FieldSet.php | 8 ++++---- model/DataObject.php | 41 +++++++++++++++++++++-------------------- model/DataObjectSet.php | 8 ++++---- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/forms/FieldSet.php b/forms/FieldSet.php index 34c13111e..195b7ab00 100644 --- a/forms/FieldSet.php +++ b/forms/FieldSet.php @@ -7,11 +7,11 @@ */ class FieldSet extends FieldList { + /** + * @deprecated 3.0.0 Use FieldList instead + */ public function __construct($items = array()) { - // user_error( - // 'FieldSet is deprecated, please use FieldList instead.', E_USER_NOTICE - // ); - + Deprecation::notice('3.0.0', 'Use FieldList instead'); parent::__construct(!is_array($items) || func_num_args() > 1 ? func_get_args(): $items); } } diff --git a/model/DataObject.php b/model/DataObject.php index d154abe74..943942a71 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -2457,10 +2457,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 2.5 Use DataObject::get() instead, with the new data mapper there's no reason not to. + * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying */ public function buildSQL($filter = "", $sort = "", $limit = "", $join = "", $restrictClasses = true, $having = "") { - user_error("DataObject::buildSQL() deprecated; just use DataObject::get() with the new data mapper", E_USER_NOTICE); + Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying'); return $this->extendedSQL($filter, $sort, $limit, $join, $having); } @@ -2471,7 +2471,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity private static $cache_buildSQL_query; /** - * @deprecated 2.5 Use DataObject::get() instead, with the new data mapper there's no reason not to. + * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying */ public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){ $dataList = DataObject::get($this->class, $filter, $sort, $join, $limit); @@ -2492,7 +2492,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return mixed The objects matching the filter, in the class specified by $containerClass */ public static function get($callerClass, $filter = "", $sort = "", $join = "", $limit = "", $containerClass = "DataList") { - // Deprecated 2.5? + // Todo: Determine if we can deprecate for 3.0.0 and use DI or something instead // Todo: Make the $containerClass method redundant if($containerClass != "DataList") user_error("The DataObject::get() \$containerClass argument has been deprecated", E_USER_NOTICE); $result = DataList::create($callerClass)->where($filter)->sort($sort)->join($join)->limit($limit); @@ -2501,9 +2501,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated + * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying */ public function Aggregate($class = null) { + Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying'); + if($class) { $list = new DataList($class); $list->setModel(DataModel::inst()); @@ -2516,9 +2518,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated + * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying */ public function RelationshipAggregate($relationship) { + Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying'); + return $this->$relationship(); } @@ -2526,7 +2530,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * The internal function that actually performs the querying for get(). * DataObject::get("Table","filter") is the same as singleton("Table")->instance_get("filter") * - * @deprecated 2.5 Use DataObject::get() + * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying * * @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. If omitted, self::$default_sort will be used. @@ -2537,15 +2541,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return mixed The objects matching the filter, in the class specified by $containerClass */ public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet") { - user_error("instance_get deprecated", E_USER_NOTICE); + Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying'); return self::get($this->class, $filter, $sort, $join, $limit, $containerClass); - } /** * Take a database {@link SS_Query} and instanciate an object for each record. * - * @deprecated 2.5 Use DataObject::get(), you don't need to side-step it any more + * @deprecated 3.0.0 Replaced by DataList * * @param SS_Query|array $records The database records, a {@link SS_Query} object or an array of maps. * @param string $containerClass The class to place all of the objects into. @@ -2553,8 +2556,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return mixed The new objects in an object of type $containerClass */ function buildDataObjectSet($records, $containerClass = "DataObjectSet", $query = null, $baseClass = null) { - user_error('buildDataObjectSet is deprecated; use DataList to do your querying', E_USER_NOTICE); - + Deprecation::notice('3.0.0', 'Replaced by DataList'); + foreach($records as $record) { if(empty($record['RecordClassName'])) { $record['RecordClassName'] = $record['ClassName']; @@ -2670,7 +2673,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity /** * Does the hard work for get_one() * - * @deprecated 2.5 Use DataObject::get_one() instead + * @deprecated 3.0.0 Use DataObject::get_one() instead * * @uses DataExtension->augmentSQL() * @@ -2679,7 +2682,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return DataObject The first item matching the query */ public function instance_get_one($filter, $orderby = null) { - user_error("DataObjct::instance_get_one is deprecated", E_USER_NOTICE); + Deprecation::notice('3.0.0', 'Use DataObject::get_one() instead'); return DataObject::get_one($this->class, $filter, true, $orderby); } @@ -2822,22 +2825,20 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 2.5 use self::database_fields() + * @deprecated 3.0.0 Use DataObject::database_fields() instead * @see DataObject::database_fields() */ public function databaseFields() { - user_error("databaseFields() is deprecated; use self::database_fields() " - . "instead", E_USER_NOTICE); + Deprecation::notice('3.0.0', 'Use DataObject::database_fields() instead'); return self::database_fields($this->class); } /** - * @deprecated 2.5 use self::custom_database_fields() + * @deprecated 3.0.0 Use DataObject::custom_database_fields() instead * @see DataObject::custom_database_fields() */ public function customDatabaseFields() { - user_error("customDatabaseFields() is deprecated; use self::custom_database_fields() " - . "instead", E_USER_NOTICE); + Deprecation::notice('3.0.0', 'Use DataObject::custom_database_fields() instead'); return self::custom_database_fields($this->class); } diff --git a/model/DataObjectSet.php b/model/DataObjectSet.php index 69f346738..852a1b2ff 100644 --- a/model/DataObjectSet.php +++ b/model/DataObjectSet.php @@ -6,11 +6,11 @@ */ class DataObjectSet extends ArrayList { + /** + * @deprecated 3.0.0 + */ public function __construct($items = array()) { - // user_error( - // 'DataObjectSet is deprecated, please use DataList or ArrayList instead.', - // E_USER_NOTICE - // ); + Deprecation::notice('3.0.0', 'Use DataList or ArrayList instead'); if ($items) { if (!is_array($items) || func_num_args() > 1) {