From e5afa25522254f07dc796967e3c0908b718536ad Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Sat, 29 Oct 2011 12:02:11 +1300 Subject: [PATCH] MINOR: Use Deprecation class to indicate deprecated methods in core. --- admin/code/LeftAndMainDecorator.php | 6 +---- control/Director.php | 3 +++ core/ClassInfo.php | 1 + core/Core.php | 1 + core/Object.php | 4 +--- core/PaginatedList.php | 2 ++ dev/Debug.php | 15 ++++++++----- filesystem/File.php | 4 ++++ filesystem/Upload.php | 12 +++++----- forms/ComplexTableField.php | 4 ++-- forms/CompositeField.php | 1 + forms/FieldSet.php | 4 ++-- forms/Form.php | 2 ++ forms/FormField.php | 1 + forms/TableListField.php | 5 ++++- forms/Validator.php | 3 +++ model/ComponentSet.php | 3 +-- model/DataExtension.php | 2 +- model/DataObject.php | 35 +++++++++++++++-------------- model/DataObjectDecorator.php | 6 +---- model/DataObjectSet.php | 4 ++-- model/DataQuery.php | 1 + model/ManyManyList.php | 1 + model/fieldtypes/Currency.php | 5 +++++ security/BasicAuth.php | 4 ++-- security/Group.php | 3 ++- security/Member.php | 13 ++++++----- security/Security.php | 2 ++ view/ArrayData.php | 1 + view/SSTemplateParser.php.inc | 1 + view/ViewableData.php | 2 +- 31 files changed, 89 insertions(+), 62 deletions(-) diff --git a/admin/code/LeftAndMainDecorator.php b/admin/code/LeftAndMainDecorator.php index eb3480ce5..96a83fffc 100644 --- a/admin/code/LeftAndMainDecorator.php +++ b/admin/code/LeftAndMainDecorator.php @@ -7,11 +7,7 @@ abstract class LeftAndMainDecorator extends LeftAndMainExtension { public function __construct() { - // TODO Re-enable before we release 3.0 beta, for now it "breaks" too many modules - // user_error( - // 'LeftAndMainDecorator is deprecated, please use LeftAndMainExtension instead.', - // E_USER_NOTICE - // ); + Deprecation::notice('3.0', 'Use LeftAndMainExtension instead.'); parent::__construct(); } diff --git a/control/Director.php b/control/Director.php index b248b05e3..040c848b8 100644 --- a/control/Director.php +++ b/control/Director.php @@ -282,6 +282,7 @@ class Director { * @deprecated 3.0 Use SS_HTTPRequest->latestParam() */ static function urlParam($name) { + Deprecation::notice('3.0', 'Use SS_HTTPRequest->latestParam() instead.'); if(isset(Director::$urlParams[$name])) return Director::$urlParams[$name]; } @@ -291,6 +292,7 @@ class Director { * @deprecated 3.0 Use SS_HTTPRequest->latestParams() */ static function urlParams() { + Deprecation::notice('3.0', 'Use SS_HTTPRequest->latestParams() instead.'); return Director::$urlParams; } @@ -413,6 +415,7 @@ class Director { * @deprecated 2.5 Use Controller->redirectBack() */ static function redirectBack() { + Deprecation::notice('2.5', 'Use Controller->redirectBack() instead.'); Controller::curr()->redirectBack(); } diff --git a/core/ClassInfo.php b/core/ClassInfo.php index 3e23cf524..3cfd1c910 100644 --- a/core/ClassInfo.php +++ b/core/ClassInfo.php @@ -181,6 +181,7 @@ class ClassInfo { * @deprecated 3.0 Please use is_subclass_of. */ public static function is_subclass_of($class, $parent) { + Deprecation::notice('3.0', 'Use is_subclass_of() instead.'); return is_subclass_of($class, $parent); } diff --git a/core/Core.php b/core/Core.php index 13c355829..bac9704af 100644 --- a/core/Core.php +++ b/core/Core.php @@ -318,6 +318,7 @@ function getTempFolder($base = null) { * @deprecated 3.0 Please use {@link SS_ClassManifest::getItemPath()}. */ function getClassFile($className) { + Deprecation::notice('3.0', 'Use SS_ClassManifest::getItemPath() instead.'); return SS_ClassLoader::instance()->getManifest()->getItemPath($className); } diff --git a/core/Object.php b/core/Object.php index 2fa517ab7..8c3e5b6a4 100755 --- a/core/Object.php +++ b/core/Object.php @@ -896,9 +896,7 @@ abstract class Object { * @deprecated */ public function set_uninherited() { - user_error ( - 'Object->set_uninherited() is deprecated, please use a custom static on your object', E_USER_WARNING - ); + Deprecation::notice('2.4', 'Use a custom static on your object instead.'); } // ----------------------------------------------------------------------------------------------------------------- diff --git a/core/PaginatedList.php b/core/PaginatedList.php index f6fe65f0b..779021d6e 100644 --- a/core/PaginatedList.php +++ b/core/PaginatedList.php @@ -388,6 +388,7 @@ class PaginatedList extends SS_ListDecorator { * @deprecated 3.0 Use individual getter methods. */ public function getPageLimits() { + Deprecation::notice('3.0', 'Use getPageStart, getPageLength, or getTotalItems instead.'); return array( 'pageStart' => $this->getPageStart(), 'pageLength' => $this->pageLength, @@ -399,6 +400,7 @@ class PaginatedList extends SS_ListDecorator { * @deprecated 3.0 Use individual setter methods. */ public function setPageLimits($pageStart, $pageLength, $totalSize) { + Deprecation::notice('3.0', 'Use setPageStart, setPageLength, or setTotalItems instead.'); $this->setPageStart($pageStart); $this->setPageLength($pageLength); $this->setTotalSize($totalSize); diff --git a/dev/Debug.php b/dev/Debug.php index 1e04363e4..f568a8f63 100644 --- a/dev/Debug.php +++ b/dev/Debug.php @@ -460,8 +460,7 @@ class Debug { * @return boolean */ static function emailError($emailAddress, $errno, $errstr, $errfile, $errline, $errcontext, $errorType = "Error") { - user_error('Debug::send_errors_to() and Debug::emailError() is deprecated. Please use SS_Log instead. - See the class documentation in SS_Log.php for more information.', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use SS_Log instead. See the class documentation in SS_Log.php for more information.'); $priority = ($errorType == 'Error') ? SS_Log::ERR : SS_Log::WARN; $writer = new SS_LogEmailWriter($emailAddress); SS_Log::add_writer($writer, $priority); @@ -489,8 +488,7 @@ class Debug { * @deprecated 2.5 See SS_Log on setting up error file logging */ protected static function log_error_if_necessary($errno, $errstr, $errfile, $errline, $errcontext, $errtype) { - user_error('Debug::log_error_if_necessary() and Debug::log_errors_to() are deprecated. Please use SS_Log instead. - See the class documentation in SS_Log.php for more information.', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use SS_Log instead. See the class documentation in SS_Log.php for more information.'); $priority = ($errtype == 'Error') ? SS_Log::ERR : SS_Log::WARN; $writer = new SS_LogFileWriter('../' . self::$log_errors_to); SS_Log::add_writer($writer, $priority); @@ -534,6 +532,7 @@ class Debug { * @param string $sendWarnings Set to true to send warnings as well as errors (Default: false) */ static function send_errors_to($emailAddress, $sendWarnings = false) { + Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error email notification.'); self::$send_errors_to = $emailAddress; self::$send_warnings_to = $sendWarnings ? $emailAddress : null; } @@ -543,6 +542,7 @@ class Debug { * @deprecated 2.5 See SS_Log on setting up error email notification */ static function get_send_errors_to() { + Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error email notification.'); return self::$send_errors_to; } @@ -551,6 +551,7 @@ class Debug { * @deprecated 2.5 See SS_Log on setting up error email notification */ static function send_warnings_to($emailAddress) { + Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error email notification.'); self::$send_warnings_to = $emailAddress; } @@ -559,6 +560,7 @@ class Debug { * @deprecated 2.5 See SS_Log on setting up error email notification */ static function get_send_warnings_to() { + Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error email notification.'); return self::$send_warnings_to; } @@ -567,6 +569,7 @@ class Debug { * @deprecated 2.5 See SS_Log on setting up error file logging */ static function log_errors_to($logFile = ".sserrors") { + Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error file logging.'); self::$log_errors_to = $logFile; } @@ -584,7 +587,7 @@ class Debug { * @deprecated 2.5 Please use {@link SS_Backtrace::backtrace()} */ static function backtrace($returnVal = false, $ignoreAjax = false) { - user_error('Debug::backtrace() is deprecated. Please use SS_Backtrace::backtrace() instead', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use SS_Backtrace::backtrace instead.'); return SS_Backtrace::backtrace($returnVal, $ignoreAjax); } @@ -592,7 +595,7 @@ class Debug { * @deprecated 2.5 Please use {@link SS_Backtrace::get_rendered_backtrace()} */ static function get_rendered_backtrace($bt, $plainText = false) { - user_error('Debug::get_rendered_backtrace() is deprecated. Please use SS_Backtrace::get_rendered_backtrace() instead', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use SS_Backtrace::get_rendered_backtrace() instead.'); return SS_Backtrace::get_rendered_backtrace($bt, $plainText); } diff --git a/filesystem/File.php b/filesystem/File.php index 36a36c311..e97b9271e 100644 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -173,6 +173,7 @@ class File extends DataObject { * @deprecated 3.0 Use getTreeTitle() */ function TreeTitle() { + Deprecation::notice('3.0', 'Use getTreeTitle() instead.'); return $this->getTreeTitle(); } @@ -513,6 +514,7 @@ class File extends DataObject { * @deprecated 2.4 */ function getLinkedURL() { + Deprecation::notice('2.4', 'Use getTreeTitle() instead.'); return "$this->Name"; } @@ -689,6 +691,8 @@ class File extends DataObject { * @deprecated alternative_instance_get() */ public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet", $having="") { + Deprecation::notice('2.5', 'Use alternative_instance_get() instead.'); + $query = $this->extendedSQL($filter, $sort, $limit, $join, $having); $baseTable = reset($query->from); diff --git a/filesystem/Upload.php b/filesystem/Upload.php index 9fb13dd17..e042dc5dc 100644 --- a/filesystem/Upload.php +++ b/filesystem/Upload.php @@ -227,7 +227,7 @@ class Upload extends Controller { * @return int Filesize in bytes */ public function getAllowedMaxFileSize($ext = null) { - user_error('Upload::getAllowedMaxFileSize() is deprecated. Please use Upload_Validator::getAllowedMaxFileSize() instead', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use Upload_Validator::getAllowedMaxFileSize() instead.'); return $this->validator->getAllowedMaxFileSize($ext); } @@ -246,7 +246,7 @@ class Upload extends Controller { * @param array|int $rules */ public function setAllowedMaxFileSize($rules) { - user_error('Upload::setAllowedMaxFileSize() is deprecated. Please use Upload_Validator::setAllowedMaxFileSize() instead', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use Upload_Validator::setAllowedMaxFileSize() instead.'); $this->validator->setAllowedMaxFileSize($rules); } @@ -255,7 +255,7 @@ class Upload extends Controller { * @return array */ public function getAllowedExtensions() { - user_error('Upload::getAllowedExtensions() is deprecated. Please use Upload_Validator::getAllowedExtensions() instead', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use Upload_Validator::getAllowedExtensions() instead.'); return $this->validator->getAllowedExtensions(); } @@ -264,7 +264,7 @@ class Upload extends Controller { * @param array $rules */ public function setAllowedExtensions($rules) { - user_error('Upload::setAllowedExtensions() is deprecated. Please use Upload_Validator::setAllowedExtensions() instead', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use Upload_Validator::setAllowedExtensions() instead.'); $this->validator->setAllowedExtensions($rules); } @@ -279,7 +279,7 @@ class Upload extends Controller { * @return boolean */ public function isValidSize($tmpFile) { - user_error('Upload::isValidSize() is deprecated. Please use Upload_Validator::isValidSize() instead', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use Upload_Validator::isValidSize() instead.'); $validator = new Upload_Validator(); $validator->setTmpFile($tmpFile); return $validator->isValidSize(); @@ -294,7 +294,7 @@ class Upload extends Controller { * @return boolean */ public function isValidExtension($tmpFile) { - user_error('Upload::isValidExtension() is deprecated. Please use Upload_Validator::isValidExtension() instead', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use Upload_Validator::isValidExtension() instead.'); $validator = new Upload_Validator(); $validator->setTmpFile($tmpFile); return $validator->isValidExtension(); diff --git a/forms/ComplexTableField.php b/forms/ComplexTableField.php index f7697c557..9120a681b 100644 --- a/forms/ComplexTableField.php +++ b/forms/ComplexTableField.php @@ -444,10 +444,10 @@ JS; } /** - * @deprecated + * @deprecated 3.0 */ function setRelationAutoSetting($value) { - user_error("ComplexTableField::setRelationAutoSetting() is deprecated; manipulate the DataList instead", E_USER_WARNING); + Deprecation::notice('3.0', 'Manipulate the DataList instead.'); } /** diff --git a/forms/CompositeField.php b/forms/CompositeField.php index 2e0e2c041..7ca6aabc6 100644 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -56,6 +56,7 @@ class CompositeField extends FormField { * @deprecated 3.0 Please use {@link FieldList()}. */ public function FieldSet() { + Deprecation::notice('3.0', 'Use FieldList() instead.'); return $this->FieldList(); } diff --git a/forms/FieldSet.php b/forms/FieldSet.php index 195b7ab00..307015c87 100644 --- a/forms/FieldSet.php +++ b/forms/FieldSet.php @@ -8,10 +8,10 @@ class FieldSet extends FieldList { /** - * @deprecated 3.0.0 Use FieldList instead + * @deprecated 3.0 Use FieldList instead */ public function __construct($items = array()) { - Deprecation::notice('3.0.0', 'Use FieldList instead'); + Deprecation::notice('3.0', 'Use FieldList instead.'); parent::__construct(!is_array($items) || func_num_args() > 1 ? func_get_args(): $items); } } diff --git a/forms/Form.php b/forms/Form.php index 15f2641ff..b58e7bd26 100644 --- a/forms/Form.php +++ b/forms/Form.php @@ -1215,6 +1215,7 @@ class Form extends RequestHandler { * @deprecated 2.5 Use SecurityToken::disable() */ static function disable_all_security_tokens() { + Deprecation::notice('2.5', 'Use SecurityToken::disable() instead.'); SecurityToken::disable(); } @@ -1227,6 +1228,7 @@ class Form extends RequestHandler { * @return bool */ function securityTokenEnabled() { + Deprecation::notice('2.5', 'Use Form->getSecurityToken()->isEnabled() instead.'); return $this->securityToken->isEnabled(); } diff --git a/forms/FormField.php b/forms/FormField.php index fb16ce2cb..8343e1460 100644 --- a/forms/FormField.php +++ b/forms/FormField.php @@ -127,6 +127,7 @@ class FormField extends RequestHandler { * @deprecated 3.0 Use {@link getName()}. */ public function Name() { + Deprecation::notice('3.0', 'Use getName() instead.'); return $this->getName(); } diff --git a/forms/TableListField.php b/forms/TableListField.php index c00cde642..876cdbefd 100644 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -473,6 +473,7 @@ JS * @deprecated Use getDataList() instead. */ function getQuery() { + Deprecation::notice('3.0', 'Use getDataList() instead.'); $list = $this->getDataList(); if(method_exists($list,'dataQuery')) { return $this->getDataList()->dataQuery()->query(); @@ -483,6 +484,7 @@ JS * @deprecated Use getCsvDataList() instead. */ function getCsvQuery() { + Deprecation::notice('3.0', 'Use getCsvDataList() instead.'); $list = $this->getCsvDataList(); if(method_exists($list,'dataQuery')) { return $list->dataQuery()->query(); @@ -745,7 +747,7 @@ JS * @deprecated Put the query string onto your form's link instead :-) */ function setExtraLinkParams($params){ - user_error("TableListField::setExtraLinkParams() deprecated - put the query string onto your form's FormAction instead; it will be handed down to all field with special handlers", E_USER_NOTICE); + Deprecation::notice('2.4', 'Put the query string onto your FormAction instead().'); $this->extraLinkParams = $params; } @@ -1086,6 +1088,7 @@ JS * @deprecated Please use the standard URL through Link() which gives you the FieldHolder as an HTML fragment. */ function ajax_refresh() { + Deprecation::notice('2.4', 'Please use the standard URL through Link() which gives you the FieldHolder as an HTML fragment instead.'); // compute sourceItems here instead of Items() to ensure that // pagination and filters are respected on template accessors //$this->sourceItems(); diff --git a/forms/Validator.php b/forms/Validator.php index b6c48648a..960edc998 100644 --- a/forms/Validator.php +++ b/forms/Validator.php @@ -127,6 +127,7 @@ abstract class Validator extends Object { * @deprecated 2.4 Use Validator->getErrors() and custom code */ function showError() { + Deprecation::notice('2.4', 'Use Validator->getErrors() and custom code instead.'); Debug::show($this->errors); } @@ -134,6 +135,7 @@ abstract class Validator extends Object { * @deprecated 2.4 Use custom code */ function getCombinedError(){ + Deprecation::notice('2.4', 'Use custom code instead.'); if($this->errors) { foreach($this->errors as $error){ $ret['message'] .= $error['message']."
"; @@ -148,6 +150,7 @@ abstract class Validator extends Object { * @deprecated 2.4 Use getErrors() */ function getError(){ + Deprecation::notice('2.4', 'Use getErrors() instead.'); return $this->getErrors(); } diff --git a/model/ComponentSet.php b/model/ComponentSet.php index 5d1d251e6..ffb4336b4 100644 --- a/model/ComponentSet.php +++ b/model/ComponentSet.php @@ -3,8 +3,7 @@ * @deprecated 3.0 Use ManyManyList or HasManyList */ class ComponentSet extends DataObjectSet { - function setComponentInfo($type, $ownerObj, $ownerClass, $tableName, $childClass, $joinField = null) { - user_error("ComponentSet is deprecated; use HasManyList or ManyManyList", E_USER_WARNING); + Deprecation::notice('3.0', 'Use ManyManyList or HasManyList instead.'); } } \ No newline at end of file diff --git a/model/DataExtension.php b/model/DataExtension.php index 2a3692b80..33c273205 100644 --- a/model/DataExtension.php +++ b/model/DataExtension.php @@ -53,7 +53,7 @@ abstract class DataExtension extends Extension { // @deprecated 2.4 - use extraStatics() now, not extraDBFields() if(method_exists($extensionClass, 'extraDBFields')) { - user_error('DataExtension::extraDBFields() is deprecated. Please use extraStatics() instead.', E_USER_NOTICE); + Deprecation::notice('2.4', 'DataExtension::extraDBFields() is deprecated. Please use extraStatics() instead.'); $extraStaticsMethod = 'extraDBFields'; } else { $extraStaticsMethod = 'extraStatics'; diff --git a/model/DataObject.php b/model/DataObject.php index e8f72e04a..3eda4742c 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -2457,10 +2457,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.0 Use DataObject::get and DataList to do your querying */ public function buildSQL($filter = "", $sort = "", $limit = "", $join = "", $restrictClasses = true, $having = "") { - Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying'); + Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); return $this->extendedSQL($filter, $sort, $limit, $join, $having); } @@ -2471,9 +2471,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity private static $cache_buildSQL_query; /** - * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.0 Use DataObject::get and DataList to do your querying */ public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){ + Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); $dataList = DataObject::get($this->class, $filter, $sort, $join, $limit); return $dataList->dataQuery()->query(); } @@ -2501,10 +2502,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.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'); + Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); if($class) { $list = new DataList($class); @@ -2518,10 +2519,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 3.0.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.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'); + Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); return $this->$relationship(); } @@ -2530,7 +2531,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 3.0.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.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. @@ -2541,14 +2542,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") { - Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying'); + Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); return self::get($this->class, $filter, $sort, $join, $limit, $containerClass); } /** * Take a database {@link SS_Query} and instanciate an object for each record. * - * @deprecated 3.0.0 Replaced by DataList + * @deprecated 3.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. @@ -2556,7 +2557,7 @@ 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) { - Deprecation::notice('3.0.0', 'Replaced by DataList'); + Deprecation::notice('3.0', 'Use DataList instead.'); foreach($records as $record) { if(empty($record['RecordClassName'])) { @@ -2673,7 +2674,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity /** * Does the hard work for get_one() * - * @deprecated 3.0.0 Use DataObject::get_one() instead + * @deprecated 3.0 Use DataObject::get_one() instead * * @uses DataExtension->augmentSQL() * @@ -2682,7 +2683,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return DataObject The first item matching the query */ public function instance_get_one($filter, $orderby = null) { - Deprecation::notice('3.0.0', 'Use DataObject::get_one() instead'); + Deprecation::notice('3.0', 'Use DataObject::get_one() instead.'); return DataObject::get_one($this->class, $filter, true, $orderby); } @@ -2825,20 +2826,20 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 3.0.0 Use DataObject::database_fields() instead + * @deprecated 3.0 Use DataObject::database_fields() instead * @see DataObject::database_fields() */ public function databaseFields() { - Deprecation::notice('3.0.0', 'Use DataObject::database_fields() instead'); + Deprecation::notice('3.0', 'Use DataObject::database_fields() instead.'); return self::database_fields($this->class); } /** - * @deprecated 3.0.0 Use DataObject::custom_database_fields() instead + * @deprecated 3.0 Use DataObject::custom_database_fields() instead * @see DataObject::custom_database_fields() */ public function customDatabaseFields() { - Deprecation::notice('3.0.0', 'Use DataObject::custom_database_fields() instead'); + Deprecation::notice('3.0', 'Use DataObject::custom_database_fields() instead.'); return self::custom_database_fields($this->class); } diff --git a/model/DataObjectDecorator.php b/model/DataObjectDecorator.php index e241ff2d3..b651326c0 100644 --- a/model/DataObjectDecorator.php +++ b/model/DataObjectDecorator.php @@ -7,11 +7,7 @@ abstract class DataObjectDecorator extends DataExtension { public function __construct() { - // TODO Re-enable before we release 3.0 beta, for now it "breaks" too many modules - // user_error( - // 'DataObjectDecorator is deprecated, please use DataExtension instead.', - // E_USER_NOTICE - // ); + Deprecation::notice('3.0', 'Use DataExtension instead.'); parent::__construct(); } diff --git a/model/DataObjectSet.php b/model/DataObjectSet.php index 852a1b2ff..3f4deac1c 100644 --- a/model/DataObjectSet.php +++ b/model/DataObjectSet.php @@ -7,10 +7,10 @@ class DataObjectSet extends ArrayList { /** - * @deprecated 3.0.0 + * @deprecated 3.0 */ public function __construct($items = array()) { - Deprecation::notice('3.0.0', 'Use DataList or ArrayList instead'); + Deprecation::notice('3.0', 'Use DataList or ArrayList instead'); if ($items) { if (!is_array($items) || func_num_args() > 1) { diff --git a/model/DataQuery.php b/model/DataQuery.php index 36a150964..ea84f0079 100644 --- a/model/DataQuery.php +++ b/model/DataQuery.php @@ -367,6 +367,7 @@ class DataQuery { * @deprecated Use innerJoin() or leftJoin() instead. */ function join($join) { + Deprecation::notice('3.0', 'Use innerJoin() or leftJoin() instead.'); if($join) { $clone = $this; $clone->query->from[] = $join; diff --git a/model/ManyManyList.php b/model/ManyManyList.php index 41e2e3385..ff2975736 100644 --- a/model/ManyManyList.php +++ b/model/ManyManyList.php @@ -131,6 +131,7 @@ class ManyManyList extends RelationList { * @deprecated this is experimental and will change. Don't use it in your projects. */ function removeByFilter($filter) { + Deprecation::notice('3.0', 'This is experimental and will change. Don\'t use it in your projects.'); $query = new SQLQuery("*", array("\"$this->joinTable\"")); $query->delete = true; $query->where($filter); diff --git a/model/fieldtypes/Currency.php b/model/fieldtypes/Currency.php index 730211f5e..736b14bde 100644 --- a/model/fieldtypes/Currency.php +++ b/model/fieldtypes/Currency.php @@ -19,6 +19,11 @@ class Currency extends Decimal { protected static $currencySymbol = '$'; + function __construct($name, $wholeSize = 9, $decimalSize = 2, $defaultValue = 0) { + Deprecation::notice('2.5', 'Use Money class instead.'); + parent::__construct($name, $wholeSize, $decimalSize, $defaultValue); + } + /** * Returns the number as a currency, eg “$1,000.00”. */ diff --git a/security/BasicAuth.php b/security/BasicAuth.php index 8393aaba0..6c94c5390 100644 --- a/security/BasicAuth.php +++ b/security/BasicAuth.php @@ -118,7 +118,7 @@ class BasicAuth { * @deprecated Use BasicAuth::protect_entire_site() instead. */ static function enable() { - user_error("BasicAuth::enable() is deprecated. Use BasicAuth::protect_entire_site() instead.", E_USER_NOTICE); + Deprecation::notice('2.4', 'Use BasicAuth::protect_entire_site() instead.'); return self::protect_entire_site(); } @@ -126,7 +126,7 @@ class BasicAuth { * @deprecated Use BasicAuth::protect_entire_site(false) instead. */ static function disable() { - user_error("BasicAuth::disable() is deprecated. Use BasicAuth::protect_entire_site(false) instead.", E_USER_NOTICE); + Deprecation::notice('2.4', 'Use BasicAuth::protect_entire_site(false) instead.'); return self::protect_entire_site(false); } diff --git a/security/Group.php b/security/Group.php index 054586436..353f596ae 100644 --- a/security/Group.php +++ b/security/Group.php @@ -188,7 +188,7 @@ class Group extends DataObject { * @deprecated 2.5 */ public static function addToGroupByName($member, $groupcode) { - user_error('Group::addToGroupByName is deprecated. Please use $member->addToGroupByCode($groupcode)', E_USER_NOTICE); + Deprecation::notice('2.5', 'Use $member->addToGroupByCode($groupcode) instead.'); return $member->addToGroupByCode($groupcode); } @@ -291,6 +291,7 @@ class Group extends DataObject { * @deprecated 3.0 Use getTreeTitle() */ function TreeTitle() { + Deprecation::notice('3.0', 'Use getTreeTitle() instead.'); return $this->getTreeTitle(); } diff --git a/security/Member.php b/security/Member.php index aba02e3ab..af7b1f32c 100644 --- a/security/Member.php +++ b/security/Member.php @@ -792,6 +792,7 @@ class Member extends DataObject { * @return Returns TRUE if this user is an administrator. */ function isAdmin() { + Deprecation::notice('2.4', 'Use Permission::check(\'ADMIN\') instead.'); return Permission::checkMember($this, 'ADMIN'); } @@ -1431,7 +1432,7 @@ class Member_GroupSet extends ManyManyList { * @deprecated Use setByIdList() and/or a CheckboxSetField */ function setByCheckboxes(array $checkboxes, array $data) { - user_error("Member_GroupSet is deprecated and no longer works", E_USER_WARNING); + Deprecation::notice('2.4', 'Use setByIdList() and/or a CheckboxSetField instead.'); } @@ -1504,7 +1505,7 @@ class Member_GroupSet extends ManyManyList { * @deprecated Use DataList::addMany */ function addManyByGroupID($ids){ - user_error('addManyByGroupID is deprecated, use addMany', E_USER_NOTICE); + Deprecation::notice('2.4', 'Use addMany() instead.'); return $this->addMany($ids); } @@ -1513,7 +1514,7 @@ class Member_GroupSet extends ManyManyList { * @deprecated Use DataList::removeMany */ function removeManyByGroupID($groupIds) { - user_error('removeManyByGroupID is deprecated, use removeMany', E_USER_NOTICE); + Deprecation::notice('2.4', 'Use removeMany() instead.'); return $this->removeMany($ids); } @@ -1522,7 +1523,7 @@ class Member_GroupSet extends ManyManyList { * @deprecated Use DataObject::get("Group")->byIds() */ function getGroupsFromIDs($ids) { - user_error('getGroupsFromIDs is deprecated, use DataObject::get("Group")->byIds()', E_USER_NOTICE); + Deprecation::notice('2.4', 'Use DataObject::get("Group")->byIds() instead.'); return DataObject::get("Group")->byIDs($ids); } @@ -1531,7 +1532,7 @@ class Member_GroupSet extends ManyManyList { * @deprecated Group.Code is deprecated */ function addManyByCodename($codenames) { - user_error("addManyByCodename is deprecated and no longer works", E_USER_WARNING); + Deprecation::notice('2.4', 'Don\'t rely on codename'); } @@ -1539,7 +1540,7 @@ class Member_GroupSet extends ManyManyList { * @deprecated Group.Code is deprecated */ function removeManyByCodename($codenames) { - user_error("removeManyByCodename is deprecated and no longer works", E_USER_WARNING); + Deprecation::notice('2.4', 'Don\'t rely on codename'); } } diff --git a/security/Security.php b/security/Security.php index 8505be676..edddd2df8 100644 --- a/security/Security.php +++ b/security/Security.php @@ -777,6 +777,7 @@ class Security extends Controller { * store the passwords in clear text. */ public static function encrypt_passwords($encrypt) { + Deprecation::notice('2.4', 'Use PasswordEncryptor_None instead.'); self::$encryptPasswords = (bool)$encrypt; } @@ -790,6 +791,7 @@ class Security extends Controller { * @return array Returns an array of strings containing all supported encryption algorithms. */ public static function get_encryption_algorithms() { + Deprecation::notice('2.4', 'Use PasswordEncryptor::get_encryptors() instead.'); return array_keys(PasswordEncryptor::get_encryptors()); } diff --git a/view/ArrayData.php b/view/ArrayData.php index fa4916740..7a98eb7fc 100644 --- a/view/ArrayData.php +++ b/view/ArrayData.php @@ -112,6 +112,7 @@ class ArrayData extends ViewableData { * @deprecated 3.0 Use {@link ArrayData::toMap()}. */ public function getArray() { + Deprecation::notice('3.0', 'Use ArrayData::toMap() instead.'); return $this->toMap(); } diff --git a/view/SSTemplateParser.php.inc b/view/SSTemplateParser.php.inc index bbe5408da..9d89cf5e8 100644 --- a/view/SSTemplateParser.php.inc +++ b/view/SSTemplateParser.php.inc @@ -658,6 +658,7 @@ class SSTemplateParser extends Parser { * @deprecated */ function ClosedBlock_Handle_Control(&$res) { + Deprecation::notice('3.1', 'Use <% with %> or <% loop %> instead.'); return $this->ClosedBlock_Handle_Loop($res); } diff --git a/view/ViewableData.php b/view/ViewableData.php index 7e5fb0672..1a30a643e 100644 --- a/view/ViewableData.php +++ b/view/ViewableData.php @@ -715,7 +715,7 @@ class ViewableData extends Object implements IteratorAggregate { * @deprecated 3.0 */ public function BaseHref() { - user_error("Please use AbsoluteBaseURL", E_USER_WARNING); + Deprecation::notice('3.0', 'Use AbsoluteBaseURL instead.'); return $this->AbsoluteBaseURL(); }