MINOR: Use Deprecation class to indicate deprecated methods in core.

This commit is contained in:
Sam Minnee 2011-10-29 12:02:11 +13:00
parent ad9bc59d10
commit e5afa25522
31 changed files with 89 additions and 62 deletions

View File

@ -7,11 +7,7 @@
abstract class LeftAndMainDecorator extends LeftAndMainExtension { abstract class LeftAndMainDecorator extends LeftAndMainExtension {
public function __construct() { public function __construct() {
// TODO Re-enable before we release 3.0 beta, for now it "breaks" too many modules Deprecation::notice('3.0', 'Use LeftAndMainExtension instead.');
// user_error(
// 'LeftAndMainDecorator is deprecated, please use LeftAndMainExtension instead.',
// E_USER_NOTICE
// );
parent::__construct(); parent::__construct();
} }

View File

@ -282,6 +282,7 @@ class Director {
* @deprecated 3.0 Use SS_HTTPRequest->latestParam() * @deprecated 3.0 Use SS_HTTPRequest->latestParam()
*/ */
static function urlParam($name) { static function urlParam($name) {
Deprecation::notice('3.0', 'Use SS_HTTPRequest->latestParam() instead.');
if(isset(Director::$urlParams[$name])) return Director::$urlParams[$name]; if(isset(Director::$urlParams[$name])) return Director::$urlParams[$name];
} }
@ -291,6 +292,7 @@ class Director {
* @deprecated 3.0 Use SS_HTTPRequest->latestParams() * @deprecated 3.0 Use SS_HTTPRequest->latestParams()
*/ */
static function urlParams() { static function urlParams() {
Deprecation::notice('3.0', 'Use SS_HTTPRequest->latestParams() instead.');
return Director::$urlParams; return Director::$urlParams;
} }
@ -413,6 +415,7 @@ class Director {
* @deprecated 2.5 Use Controller->redirectBack() * @deprecated 2.5 Use Controller->redirectBack()
*/ */
static function redirectBack() { static function redirectBack() {
Deprecation::notice('2.5', 'Use Controller->redirectBack() instead.');
Controller::curr()->redirectBack(); Controller::curr()->redirectBack();
} }

View File

@ -181,6 +181,7 @@ class ClassInfo {
* @deprecated 3.0 Please use is_subclass_of. * @deprecated 3.0 Please use is_subclass_of.
*/ */
public static function is_subclass_of($class, $parent) { public static function is_subclass_of($class, $parent) {
Deprecation::notice('3.0', 'Use is_subclass_of() instead.');
return is_subclass_of($class, $parent); return is_subclass_of($class, $parent);
} }

View File

@ -318,6 +318,7 @@ function getTempFolder($base = null) {
* @deprecated 3.0 Please use {@link SS_ClassManifest::getItemPath()}. * @deprecated 3.0 Please use {@link SS_ClassManifest::getItemPath()}.
*/ */
function getClassFile($className) { function getClassFile($className) {
Deprecation::notice('3.0', 'Use SS_ClassManifest::getItemPath() instead.');
return SS_ClassLoader::instance()->getManifest()->getItemPath($className); return SS_ClassLoader::instance()->getManifest()->getItemPath($className);
} }

View File

@ -896,9 +896,7 @@ abstract class Object {
* @deprecated * @deprecated
*/ */
public function set_uninherited() { public function set_uninherited() {
user_error ( Deprecation::notice('2.4', 'Use a custom static on your object instead.');
'Object->set_uninherited() is deprecated, please use a custom static on your object', E_USER_WARNING
);
} }
// ----------------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------------

View File

@ -388,6 +388,7 @@ class PaginatedList extends SS_ListDecorator {
* @deprecated 3.0 Use individual getter methods. * @deprecated 3.0 Use individual getter methods.
*/ */
public function getPageLimits() { public function getPageLimits() {
Deprecation::notice('3.0', 'Use getPageStart, getPageLength, or getTotalItems instead.');
return array( return array(
'pageStart' => $this->getPageStart(), 'pageStart' => $this->getPageStart(),
'pageLength' => $this->pageLength, 'pageLength' => $this->pageLength,
@ -399,6 +400,7 @@ class PaginatedList extends SS_ListDecorator {
* @deprecated 3.0 Use individual setter methods. * @deprecated 3.0 Use individual setter methods.
*/ */
public function setPageLimits($pageStart, $pageLength, $totalSize) { public function setPageLimits($pageStart, $pageLength, $totalSize) {
Deprecation::notice('3.0', 'Use setPageStart, setPageLength, or setTotalItems instead.');
$this->setPageStart($pageStart); $this->setPageStart($pageStart);
$this->setPageLength($pageLength); $this->setPageLength($pageLength);
$this->setTotalSize($totalSize); $this->setTotalSize($totalSize);

View File

@ -460,8 +460,7 @@ class Debug {
* @return boolean * @return boolean
*/ */
static function emailError($emailAddress, $errno, $errstr, $errfile, $errline, $errcontext, $errorType = "Error") { 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. Deprecation::notice('2.5', 'Use SS_Log instead. See the class documentation in SS_Log.php for more information.');
See the class documentation in SS_Log.php for more information.', E_USER_NOTICE);
$priority = ($errorType == 'Error') ? SS_Log::ERR : SS_Log::WARN; $priority = ($errorType == 'Error') ? SS_Log::ERR : SS_Log::WARN;
$writer = new SS_LogEmailWriter($emailAddress); $writer = new SS_LogEmailWriter($emailAddress);
SS_Log::add_writer($writer, $priority); SS_Log::add_writer($writer, $priority);
@ -489,8 +488,7 @@ class Debug {
* @deprecated 2.5 See SS_Log on setting up error file logging * @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) { 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. Deprecation::notice('2.5', 'Use SS_Log instead. See the class documentation in SS_Log.php for more information.');
See the class documentation in SS_Log.php for more information.', E_USER_NOTICE);
$priority = ($errtype == 'Error') ? SS_Log::ERR : SS_Log::WARN; $priority = ($errtype == 'Error') ? SS_Log::ERR : SS_Log::WARN;
$writer = new SS_LogFileWriter('../' . self::$log_errors_to); $writer = new SS_LogFileWriter('../' . self::$log_errors_to);
SS_Log::add_writer($writer, $priority); 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) * @param string $sendWarnings Set to true to send warnings as well as errors (Default: false)
*/ */
static function send_errors_to($emailAddress, $sendWarnings = 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_errors_to = $emailAddress;
self::$send_warnings_to = $sendWarnings ? $emailAddress : null; 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 * @deprecated 2.5 See SS_Log on setting up error email notification
*/ */
static function get_send_errors_to() { 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; return self::$send_errors_to;
} }
@ -551,6 +551,7 @@ class Debug {
* @deprecated 2.5 See SS_Log on setting up error email notification * @deprecated 2.5 See SS_Log on setting up error email notification
*/ */
static function send_warnings_to($emailAddress) { 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; self::$send_warnings_to = $emailAddress;
} }
@ -559,6 +560,7 @@ class Debug {
* @deprecated 2.5 See SS_Log on setting up error email notification * @deprecated 2.5 See SS_Log on setting up error email notification
*/ */
static function get_send_warnings_to() { 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; return self::$send_warnings_to;
} }
@ -567,6 +569,7 @@ class Debug {
* @deprecated 2.5 See SS_Log on setting up error file logging * @deprecated 2.5 See SS_Log on setting up error file logging
*/ */
static function log_errors_to($logFile = ".sserrors") { 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; self::$log_errors_to = $logFile;
} }
@ -584,7 +587,7 @@ class Debug {
* @deprecated 2.5 Please use {@link SS_Backtrace::backtrace()} * @deprecated 2.5 Please use {@link SS_Backtrace::backtrace()}
*/ */
static function backtrace($returnVal = false, $ignoreAjax = false) { 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); return SS_Backtrace::backtrace($returnVal, $ignoreAjax);
} }
@ -592,7 +595,7 @@ class Debug {
* @deprecated 2.5 Please use {@link SS_Backtrace::get_rendered_backtrace()} * @deprecated 2.5 Please use {@link SS_Backtrace::get_rendered_backtrace()}
*/ */
static function get_rendered_backtrace($bt, $plainText = false) { 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); return SS_Backtrace::get_rendered_backtrace($bt, $plainText);
} }

View File

@ -173,6 +173,7 @@ class File extends DataObject {
* @deprecated 3.0 Use getTreeTitle() * @deprecated 3.0 Use getTreeTitle()
*/ */
function TreeTitle() { function TreeTitle() {
Deprecation::notice('3.0', 'Use getTreeTitle() instead.');
return $this->getTreeTitle(); return $this->getTreeTitle();
} }
@ -513,6 +514,7 @@ class File extends DataObject {
* @deprecated 2.4 * @deprecated 2.4
*/ */
function getLinkedURL() { function getLinkedURL() {
Deprecation::notice('2.4', 'Use getTreeTitle() instead.');
return "$this->Name"; return "$this->Name";
} }
@ -689,6 +691,8 @@ class File extends DataObject {
* @deprecated alternative_instance_get() * @deprecated alternative_instance_get()
*/ */
public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet", $having="") { 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); $query = $this->extendedSQL($filter, $sort, $limit, $join, $having);
$baseTable = reset($query->from); $baseTable = reset($query->from);

View File

@ -227,7 +227,7 @@ class Upload extends Controller {
* @return int Filesize in bytes * @return int Filesize in bytes
*/ */
public function getAllowedMaxFileSize($ext = null) { 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); return $this->validator->getAllowedMaxFileSize($ext);
} }
@ -246,7 +246,7 @@ class Upload extends Controller {
* @param array|int $rules * @param array|int $rules
*/ */
public function setAllowedMaxFileSize($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); $this->validator->setAllowedMaxFileSize($rules);
} }
@ -255,7 +255,7 @@ class Upload extends Controller {
* @return array * @return array
*/ */
public function getAllowedExtensions() { 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(); return $this->validator->getAllowedExtensions();
} }
@ -264,7 +264,7 @@ class Upload extends Controller {
* @param array $rules * @param array $rules
*/ */
public function setAllowedExtensions($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); $this->validator->setAllowedExtensions($rules);
} }
@ -279,7 +279,7 @@ class Upload extends Controller {
* @return boolean * @return boolean
*/ */
public function isValidSize($tmpFile) { 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 = new Upload_Validator();
$validator->setTmpFile($tmpFile); $validator->setTmpFile($tmpFile);
return $validator->isValidSize(); return $validator->isValidSize();
@ -294,7 +294,7 @@ class Upload extends Controller {
* @return boolean * @return boolean
*/ */
public function isValidExtension($tmpFile) { 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 = new Upload_Validator();
$validator->setTmpFile($tmpFile); $validator->setTmpFile($tmpFile);
return $validator->isValidExtension(); return $validator->isValidExtension();

View File

@ -444,10 +444,10 @@ JS;
} }
/** /**
* @deprecated * @deprecated 3.0
*/ */
function setRelationAutoSetting($value) { function setRelationAutoSetting($value) {
user_error("ComplexTableField::setRelationAutoSetting() is deprecated; manipulate the DataList instead", E_USER_WARNING); Deprecation::notice('3.0', 'Manipulate the DataList instead.');
} }
/** /**

View File

@ -56,6 +56,7 @@ class CompositeField extends FormField {
* @deprecated 3.0 Please use {@link FieldList()}. * @deprecated 3.0 Please use {@link FieldList()}.
*/ */
public function FieldSet() { public function FieldSet() {
Deprecation::notice('3.0', 'Use FieldList() instead.');
return $this->FieldList(); return $this->FieldList();
} }

View File

@ -8,10 +8,10 @@
class FieldSet extends FieldList { class FieldSet extends FieldList {
/** /**
* @deprecated 3.0.0 Use FieldList instead * @deprecated 3.0 Use FieldList instead
*/ */
public function __construct($items = array()) { 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); parent::__construct(!is_array($items) || func_num_args() > 1 ? func_get_args(): $items);
} }
} }

View File

@ -1215,6 +1215,7 @@ class Form extends RequestHandler {
* @deprecated 2.5 Use SecurityToken::disable() * @deprecated 2.5 Use SecurityToken::disable()
*/ */
static function disable_all_security_tokens() { static function disable_all_security_tokens() {
Deprecation::notice('2.5', 'Use SecurityToken::disable() instead.');
SecurityToken::disable(); SecurityToken::disable();
} }
@ -1227,6 +1228,7 @@ class Form extends RequestHandler {
* @return bool * @return bool
*/ */
function securityTokenEnabled() { function securityTokenEnabled() {
Deprecation::notice('2.5', 'Use Form->getSecurityToken()->isEnabled() instead.');
return $this->securityToken->isEnabled(); return $this->securityToken->isEnabled();
} }

View File

@ -127,6 +127,7 @@ class FormField extends RequestHandler {
* @deprecated 3.0 Use {@link getName()}. * @deprecated 3.0 Use {@link getName()}.
*/ */
public function Name() { public function Name() {
Deprecation::notice('3.0', 'Use getName() instead.');
return $this->getName(); return $this->getName();
} }

View File

@ -473,6 +473,7 @@ JS
* @deprecated Use getDataList() instead. * @deprecated Use getDataList() instead.
*/ */
function getQuery() { function getQuery() {
Deprecation::notice('3.0', 'Use getDataList() instead.');
$list = $this->getDataList(); $list = $this->getDataList();
if(method_exists($list,'dataQuery')) { if(method_exists($list,'dataQuery')) {
return $this->getDataList()->dataQuery()->query(); return $this->getDataList()->dataQuery()->query();
@ -483,6 +484,7 @@ JS
* @deprecated Use getCsvDataList() instead. * @deprecated Use getCsvDataList() instead.
*/ */
function getCsvQuery() { function getCsvQuery() {
Deprecation::notice('3.0', 'Use getCsvDataList() instead.');
$list = $this->getCsvDataList(); $list = $this->getCsvDataList();
if(method_exists($list,'dataQuery')) { if(method_exists($list,'dataQuery')) {
return $list->dataQuery()->query(); return $list->dataQuery()->query();
@ -745,7 +747,7 @@ JS
* @deprecated Put the query string onto your form's link instead :-) * @deprecated Put the query string onto your form's link instead :-)
*/ */
function setExtraLinkParams($params){ 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; $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. * @deprecated Please use the standard URL through Link() which gives you the FieldHolder as an HTML fragment.
*/ */
function ajax_refresh() { 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 // compute sourceItems here instead of Items() to ensure that
// pagination and filters are respected on template accessors // pagination and filters are respected on template accessors
//$this->sourceItems(); //$this->sourceItems();

View File

@ -127,6 +127,7 @@ abstract class Validator extends Object {
* @deprecated 2.4 Use Validator->getErrors() and custom code * @deprecated 2.4 Use Validator->getErrors() and custom code
*/ */
function showError() { function showError() {
Deprecation::notice('2.4', 'Use Validator->getErrors() and custom code instead.');
Debug::show($this->errors); Debug::show($this->errors);
} }
@ -134,6 +135,7 @@ abstract class Validator extends Object {
* @deprecated 2.4 Use custom code * @deprecated 2.4 Use custom code
*/ */
function getCombinedError(){ function getCombinedError(){
Deprecation::notice('2.4', 'Use custom code instead.');
if($this->errors) { if($this->errors) {
foreach($this->errors as $error){ foreach($this->errors as $error){
$ret['message'] .= $error['message']."<br />"; $ret['message'] .= $error['message']."<br />";
@ -148,6 +150,7 @@ abstract class Validator extends Object {
* @deprecated 2.4 Use getErrors() * @deprecated 2.4 Use getErrors()
*/ */
function getError(){ function getError(){
Deprecation::notice('2.4', 'Use getErrors() instead.');
return $this->getErrors(); return $this->getErrors();
} }

View File

@ -3,8 +3,7 @@
* @deprecated 3.0 Use ManyManyList or HasManyList * @deprecated 3.0 Use ManyManyList or HasManyList
*/ */
class ComponentSet extends DataObjectSet { class ComponentSet extends DataObjectSet {
function setComponentInfo($type, $ownerObj, $ownerClass, $tableName, $childClass, $joinField = null) { 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.');
} }
} }

View File

@ -53,7 +53,7 @@ abstract class DataExtension extends Extension {
// @deprecated 2.4 - use extraStatics() now, not extraDBFields() // @deprecated 2.4 - use extraStatics() now, not extraDBFields()
if(method_exists($extensionClass, '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'; $extraStaticsMethod = 'extraDBFields';
} else { } else {
$extraStaticsMethod = 'extraStatics'; $extraStaticsMethod = 'extraStatics';

View File

@ -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 = "") { 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); return $this->extendedSQL($filter, $sort, $limit, $join, $having);
} }
@ -2471,9 +2471,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
private static $cache_buildSQL_query; 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 = ""){ 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); $dataList = DataObject::get($this->class, $filter, $sort, $join, $limit);
return $dataList->dataQuery()->query(); 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) { 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) { if($class) {
$list = new DataList($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) { 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(); return $this->$relationship();
} }
@ -2530,7 +2531,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 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 $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.
@ -2541,14 +2542,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") {
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); 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 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 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.
@ -2556,7 +2557,7 @@ 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) {
Deprecation::notice('3.0.0', 'Replaced by DataList'); Deprecation::notice('3.0', 'Use DataList instead.');
foreach($records as $record) { foreach($records as $record) {
if(empty($record['RecordClassName'])) { if(empty($record['RecordClassName'])) {
@ -2673,7 +2674,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
/** /**
* Does the hard work for get_one() * 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() * @uses DataExtension->augmentSQL()
* *
@ -2682,7 +2683,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) {
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); 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() * @see DataObject::database_fields()
*/ */
public function databaseFields() { 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); 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() * @see DataObject::custom_database_fields()
*/ */
public function customDatabaseFields() { 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); return self::custom_database_fields($this->class);
} }

View File

@ -7,11 +7,7 @@
abstract class DataObjectDecorator extends DataExtension { abstract class DataObjectDecorator extends DataExtension {
public function __construct() { public function __construct() {
// TODO Re-enable before we release 3.0 beta, for now it "breaks" too many modules Deprecation::notice('3.0', 'Use DataExtension instead.');
// user_error(
// 'DataObjectDecorator is deprecated, please use DataExtension instead.',
// E_USER_NOTICE
// );
parent::__construct(); parent::__construct();
} }

View File

@ -7,10 +7,10 @@
class DataObjectSet extends ArrayList { class DataObjectSet extends ArrayList {
/** /**
* @deprecated 3.0.0 * @deprecated 3.0
*/ */
public function __construct($items = array()) { 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 ($items) {
if (!is_array($items) || func_num_args() > 1) { if (!is_array($items) || func_num_args() > 1) {

View File

@ -367,6 +367,7 @@ class DataQuery {
* @deprecated Use innerJoin() or leftJoin() instead. * @deprecated Use innerJoin() or leftJoin() instead.
*/ */
function join($join) { function join($join) {
Deprecation::notice('3.0', 'Use innerJoin() or leftJoin() instead.');
if($join) { if($join) {
$clone = $this; $clone = $this;
$clone->query->from[] = $join; $clone->query->from[] = $join;

View File

@ -131,6 +131,7 @@ class ManyManyList extends RelationList {
* @deprecated this is experimental and will change. Don't use it in your projects. * @deprecated this is experimental and will change. Don't use it in your projects.
*/ */
function removeByFilter($filter) { 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 = new SQLQuery("*", array("\"$this->joinTable\""));
$query->delete = true; $query->delete = true;
$query->where($filter); $query->where($filter);

View File

@ -19,6 +19,11 @@
class Currency extends Decimal { class Currency extends Decimal {
protected static $currencySymbol = '$'; 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. * Returns the number as a currency, eg $1,000.00.
*/ */

View File

@ -118,7 +118,7 @@ class BasicAuth {
* @deprecated Use BasicAuth::protect_entire_site() instead. * @deprecated Use BasicAuth::protect_entire_site() instead.
*/ */
static function enable() { 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(); return self::protect_entire_site();
} }
@ -126,7 +126,7 @@ class BasicAuth {
* @deprecated Use BasicAuth::protect_entire_site(false) instead. * @deprecated Use BasicAuth::protect_entire_site(false) instead.
*/ */
static function disable() { 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); return self::protect_entire_site(false);
} }

View File

@ -188,7 +188,7 @@ class Group extends DataObject {
* @deprecated 2.5 * @deprecated 2.5
*/ */
public static function addToGroupByName($member, $groupcode) { 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); return $member->addToGroupByCode($groupcode);
} }
@ -291,6 +291,7 @@ class Group extends DataObject {
* @deprecated 3.0 Use getTreeTitle() * @deprecated 3.0 Use getTreeTitle()
*/ */
function TreeTitle() { function TreeTitle() {
Deprecation::notice('3.0', 'Use getTreeTitle() instead.');
return $this->getTreeTitle(); return $this->getTreeTitle();
} }

View File

@ -792,6 +792,7 @@ class Member extends DataObject {
* @return Returns TRUE if this user is an administrator. * @return Returns TRUE if this user is an administrator.
*/ */
function isAdmin() { function isAdmin() {
Deprecation::notice('2.4', 'Use Permission::check(\'ADMIN\') instead.');
return Permission::checkMember($this, 'ADMIN'); return Permission::checkMember($this, 'ADMIN');
} }
@ -1431,7 +1432,7 @@ class Member_GroupSet extends ManyManyList {
* @deprecated Use setByIdList() and/or a CheckboxSetField * @deprecated Use setByIdList() and/or a CheckboxSetField
*/ */
function setByCheckboxes(array $checkboxes, array $data) { 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 * @deprecated Use DataList::addMany
*/ */
function addManyByGroupID($ids){ function addManyByGroupID($ids){
user_error('addManyByGroupID is deprecated, use addMany', E_USER_NOTICE); Deprecation::notice('2.4', 'Use addMany() instead.');
return $this->addMany($ids); return $this->addMany($ids);
} }
@ -1513,7 +1514,7 @@ class Member_GroupSet extends ManyManyList {
* @deprecated Use DataList::removeMany * @deprecated Use DataList::removeMany
*/ */
function removeManyByGroupID($groupIds) { function removeManyByGroupID($groupIds) {
user_error('removeManyByGroupID is deprecated, use removeMany', E_USER_NOTICE); Deprecation::notice('2.4', 'Use removeMany() instead.');
return $this->removeMany($ids); return $this->removeMany($ids);
} }
@ -1522,7 +1523,7 @@ class Member_GroupSet extends ManyManyList {
* @deprecated Use DataObject::get("Group")->byIds() * @deprecated Use DataObject::get("Group")->byIds()
*/ */
function getGroupsFromIDs($ids) { 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); return DataObject::get("Group")->byIDs($ids);
} }
@ -1531,7 +1532,7 @@ class Member_GroupSet extends ManyManyList {
* @deprecated Group.Code is deprecated * @deprecated Group.Code is deprecated
*/ */
function addManyByCodename($codenames) { 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 * @deprecated Group.Code is deprecated
*/ */
function removeManyByCodename($codenames) { function removeManyByCodename($codenames) {
user_error("removeManyByCodename is deprecated and no longer works", E_USER_WARNING); Deprecation::notice('2.4', 'Don\'t rely on codename');
} }
} }

View File

@ -777,6 +777,7 @@ class Security extends Controller {
* store the passwords in clear text. * store the passwords in clear text.
*/ */
public static function encrypt_passwords($encrypt) { public static function encrypt_passwords($encrypt) {
Deprecation::notice('2.4', 'Use PasswordEncryptor_None instead.');
self::$encryptPasswords = (bool)$encrypt; self::$encryptPasswords = (bool)$encrypt;
} }
@ -790,6 +791,7 @@ class Security extends Controller {
* @return array Returns an array of strings containing all supported encryption algorithms. * @return array Returns an array of strings containing all supported encryption algorithms.
*/ */
public static function get_encryption_algorithms() { public static function get_encryption_algorithms() {
Deprecation::notice('2.4', 'Use PasswordEncryptor::get_encryptors() instead.');
return array_keys(PasswordEncryptor::get_encryptors()); return array_keys(PasswordEncryptor::get_encryptors());
} }

View File

@ -112,6 +112,7 @@ class ArrayData extends ViewableData {
* @deprecated 3.0 Use {@link ArrayData::toMap()}. * @deprecated 3.0 Use {@link ArrayData::toMap()}.
*/ */
public function getArray() { public function getArray() {
Deprecation::notice('3.0', 'Use ArrayData::toMap() instead.');
return $this->toMap(); return $this->toMap();
} }

View File

@ -658,6 +658,7 @@ class SSTemplateParser extends Parser {
* @deprecated * @deprecated
*/ */
function ClosedBlock_Handle_Control(&$res) { function ClosedBlock_Handle_Control(&$res) {
Deprecation::notice('3.1', 'Use <% with %> or <% loop %> instead.');
return $this->ClosedBlock_Handle_Loop($res); return $this->ClosedBlock_Handle_Loop($res);
} }

View File

@ -715,7 +715,7 @@ class ViewableData extends Object implements IteratorAggregate {
* @deprecated 3.0 * @deprecated 3.0
*/ */
public function BaseHref() { public function BaseHref() {
user_error("Please use AbsoluteBaseURL", E_USER_WARNING); Deprecation::notice('3.0', 'Use AbsoluteBaseURL instead.');
return $this->AbsoluteBaseURL(); return $this->AbsoluteBaseURL();
} }