MINOR: Fix deprecated notices - change old references to 2.5 from ORM work to 3.0.0, and use new deprecation notice system

This commit is contained in:
Hamish Friedlander 2011-10-28 14:36:20 +13:00
parent e5ea2ea94d
commit 4c0105a3c4
3 changed files with 29 additions and 28 deletions

View File

@ -7,11 +7,11 @@
*/ */
class FieldSet extends FieldList { class FieldSet extends FieldList {
/**
* @deprecated 3.0.0 Use FieldList instead
*/
public function __construct($items = array()) { public function __construct($items = array()) {
// user_error( Deprecation::notice('3.0.0', 'Use FieldList instead');
// 'FieldSet is deprecated, please use FieldList instead.', E_USER_NOTICE
// );
parent::__construct(!is_array($items) || func_num_args() > 1 ? func_get_args(): $items); parent::__construct(!is_array($items) || func_num_args() > 1 ? func_get_args(): $items);
} }
} }

View File

@ -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 = "") { 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); return $this->extendedSQL($filter, $sort, $limit, $join, $having);
} }
@ -2471,7 +2471,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
private static $cache_buildSQL_query; 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 = ""){ public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){
$dataList = DataObject::get($this->class, $filter, $sort, $join, $limit); $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 * @return mixed The objects matching the filter, in the class specified by $containerClass
*/ */
public static function get($callerClass, $filter = "", $sort = "", $join = "", $limit = "", $containerClass = "DataList") { 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 // Todo: Make the $containerClass method redundant
if($containerClass != "DataList") user_error("The DataObject::get() \$containerClass argument has been deprecated", E_USER_NOTICE); 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); $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) { public function Aggregate($class = null) {
Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying');
if($class) { if($class) {
$list = new DataList($class); $list = new DataList($class);
$list->setModel(DataModel::inst()); $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) { public function RelationshipAggregate($relationship) {
Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying');
return $this->$relationship(); return $this->$relationship();
} }
@ -2526,7 +2530,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* The internal function that actually performs the querying for get(). * The internal function that actually performs the querying for get().
* DataObject::get("Table","filter") is the same as singleton("Table")->instance_get("filter") * 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 $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. * @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 * @return mixed The objects matching the filter, in the class specified by $containerClass
*/ */
public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet") { 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); return self::get($this->class, $filter, $sort, $join, $limit, $containerClass);
} }
/** /**
* Take a database {@link SS_Query} and instanciate an object for each record. * 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 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. * @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 * @return mixed The new objects in an object of type $containerClass
*/ */
function buildDataObjectSet($records, $containerClass = "DataObjectSet", $query = null, $baseClass = null) { 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) { foreach($records as $record) {
if(empty($record['RecordClassName'])) { if(empty($record['RecordClassName'])) {
$record['RecordClassName'] = $record['ClassName']; $record['RecordClassName'] = $record['ClassName'];
@ -2670,7 +2673,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
/** /**
* Does the hard work for get_one() * 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() * @uses DataExtension->augmentSQL()
* *
@ -2679,7 +2682,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* @return DataObject The first item matching the query * @return DataObject The first item matching the query
*/ */
public function instance_get_one($filter, $orderby = null) { 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); 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() * @see DataObject::database_fields()
*/ */
public function databaseFields() { public function databaseFields() {
user_error("databaseFields() is deprecated; use self::database_fields() " Deprecation::notice('3.0.0', 'Use DataObject::database_fields() instead');
. "instead", E_USER_NOTICE);
return self::database_fields($this->class); 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() * @see DataObject::custom_database_fields()
*/ */
public function customDatabaseFields() { public function customDatabaseFields() {
user_error("customDatabaseFields() is deprecated; use self::custom_database_fields() " Deprecation::notice('3.0.0', 'Use DataObject::custom_database_fields() instead');
. "instead", E_USER_NOTICE);
return self::custom_database_fields($this->class); return self::custom_database_fields($this->class);
} }

View File

@ -6,11 +6,11 @@
*/ */
class DataObjectSet extends ArrayList { class DataObjectSet extends ArrayList {
/**
* @deprecated 3.0.0
*/
public function __construct($items = array()) { public function __construct($items = array()) {
// user_error( Deprecation::notice('3.0.0', 'Use DataList or ArrayList instead');
// 'DataObjectSet is deprecated, please use DataList or ArrayList instead.',
// E_USER_NOTICE
// );
if ($items) { if ($items) {
if (!is_array($items) || func_num_args() > 1) { if (!is_array($items) || func_num_args() > 1) {