From 50b2f7180f916db8d407418237422ec01f1b5235 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Tue, 18 Dec 2007 22:50:23 +0000 Subject: [PATCH] Throw a E_USER_NOTICE on use of deprecated functions git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47306 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/Convert.php | 29 +++++++++++++++++++++-------- core/Debug.php | 3 ++- core/control/Controller.php | 3 ++- core/control/Director.php | 25 +++++++++++++++++++++---- core/model/DataObjectSet.php | 1 + core/model/fieldtypes/Datetime.php | 4 ++++ forms/FormField.php | 5 +++-- 7 files changed, 54 insertions(+), 16 deletions(-) diff --git a/core/Convert.php b/core/Convert.php index 15f2b6965..927f1d3e0 100755 --- a/core/Convert.php +++ b/core/Convert.php @@ -279,27 +279,40 @@ class Convert extends Object { * * @param $val the string you wish to convert * @return the HTML version of the string + * @deprecated */ static function raw2html($val) { - user_error("Convert::raw2html is deprecated. Used Convert::raw2xml instead", E_USER_WARNING); + user_error("Convert::raw2html is deprecated. Used Convert::raw2xml instead", E_USER_NOTICE); return self::raw2xml($val); } - + + /** + * @deprecated + */ static function html2plain($val){ - user_error("html2plain is deprecated. Use xml2raw instead.", E_USER_WARNING); + user_error("html2plain is deprecated. Use xml2raw instead.", E_USER_NOTICE); return self::html2raw($val); } - + + /** + * @deprecated + */ static function html2text($val, $preserveLinks = false) { - user_error("html2text is deprecated. Use xml2raw instead.", E_USER_WARNING); + user_error("html2text is deprecated. Use xml2raw instead.", E_USER_NOTICE); return self::html2raw($val); } - + + /** + * @deprecated + */ static function raw2reserveNL($val){ - user_error("Convert::raw2reserveNL is deprecated. Used Convert::raw2xml instead", E_USER_WARNING); + user_error("Convert::raw2reserveNL is deprecated. Used Convert::raw2xml instead", E_USER_NOTICE); return self::raw2xml($val); } - + + /** + * @deprecated + */ static function raw2attr($val) { user_error("raw2attr is deprecated. Use raw2att instead.", E_USER_WARNING); return self::raw2att($val); diff --git a/core/Debug.php b/core/Debug.php index f17c5131b..a8e6a7757 100644 --- a/core/Debug.php +++ b/core/Debug.php @@ -214,9 +214,10 @@ class Debug { /** * Deprecated. Send live errors and warnings to the given address. - * Use send_errors_to() instead. + * @deprecated Use send_errors_to() instead. */ static function sendLiveErrorsTo($emailAddress) { + user_error('Debug::sendLiveErrorsTo() is deprecated. Use Director::send_errors_to() instead.', E_USER_NOTICE); if(!Director::isDev()) self::send_errors_to($emailAddress, true); } diff --git a/core/control/Controller.php b/core/control/Controller.php index 3f6f8c787..c900f36c9 100644 --- a/core/control/Controller.php +++ b/core/control/Controller.php @@ -311,10 +311,11 @@ class Controller extends ViewableData { } /** - * Deprecated - use Controller::curr() instead + * @deprecated use Controller::curr() instead * @returns Controller */ public static function currentController() { + user_error('Controller::currentController() is deprecated. Use Controller::curr() instead.', E_USER_NOTICE); return self::curr(); } diff --git a/core/control/Director.php b/core/control/Director.php index 941bba73e..3591fc3ec 100644 --- a/core/control/Director.php +++ b/core/control/Director.php @@ -506,11 +506,28 @@ class Director { } /** - * @todo These functions are deprecated, let's use isLive isDev and isTest instead. + * @deprecated use isDev() instead */ - function isDevMode() { return self::isDev(); } - function isTestMode() { return self::isTest(); } - function isLiveMode() { return self::isLive(); } + function isDevMode() { + user_error('Director::isDevMode() is deprecated. Use Director::isDev() instead.', E_USER_NOTICE); + return self::isDev(); + } + + /** + * @deprecated use isTest() instead + */ + function isTestMode() { + user_error('Director::isTestMode() is deprecated. Use Director::isTest() instead.', E_USER_NOTICE); + return self::isTest(); + } + + /** + * @deprecated use isLive() instead + */ + function isLiveMode() { + user_error('Director::isLiveMode() is deprecated. Use Director::isLive() instead.', E_USER_NOTICE); + return self::isLive(); + } } diff --git a/core/model/DataObjectSet.php b/core/model/DataObjectSet.php index cc6d49a41..650b6c4f9 100644 --- a/core/model/DataObjectSet.php +++ b/core/model/DataObjectSet.php @@ -386,6 +386,7 @@ class DataObjectSet extends ViewableData implements Iterator { * @deprecated Use merge() */ public function append(DataObjectSet $doset){ + user_error('DataObjectSet::append() is deprecated. Use DataObjectSet::merge() instead.', E_USER_NOTICE); foreach($doset as $item){ $this->push($item); } diff --git a/core/model/fieldtypes/Datetime.php b/core/model/fieldtypes/Datetime.php index dd3f97db5..9eb8c09be 100644 --- a/core/model/fieldtypes/Datetime.php +++ b/core/model/fieldtypes/Datetime.php @@ -2,6 +2,10 @@ if(!class_exists('Datetime')) { class Datetime extends Date { + function __construct($name) { + user_error('Datetime is deprecated. Use SSDatetime instead.', E_USER_NOTICE); + parent::__construct($name); + } function setValue($value) { if($value) $this->value = date('Y-m-d H:i:s', strtotime($value)); diff --git a/forms/FormField.php b/forms/FormField.php index c8ad27f8b..b39b98fd8 100644 --- a/forms/FormField.php +++ b/forms/FormField.php @@ -393,9 +393,10 @@ HTML; // ################### /** - * DEPRECATED Please use addExtraClass + * @deprecated please use addExtraClass */ - function setExtraClass($extraClass){ + function setExtraClass($extraClass) { + user_error('FormField::setExtraClass() is deprecated. Use FormField::addExtraClass() instead.', E_USER_NOTICE); $this->extraClasses[] = $extraClass; } }