aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-02-01 00:53:06 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-02-01 00:53:06 +0000
commitced1f7e98a99b4bd702a362ddd1968ff1e2ae5f0 (patch)
tree64b4cba6c6ced5e7f7f8b28164134e7c45e4bfb4 /engine/lib/elgglib.php
parentbecacf9b043c2526e910d84fe41b96e800aca602 (diff)
downloadelgg-ced1f7e98a99b4bd702a362ddd1968ff1e2ae5f0.tar.gz
elgg-ced1f7e98a99b4bd702a362ddd1968ff1e2ae5f0.tar.bz2
Add elgg_deprecated_notice() so we don't have to re-write all the elgg_log() deprecated notices to register_error()s. Updated current ones to use this.
git-svn-id: http://code.elgg.org/elgg/trunk@3874 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php53
1 files changed, 51 insertions, 2 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 698a34b93..cd426309d 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -561,7 +561,7 @@ function elgg_get_views($dir, $base) {
* @param $base
*/
function get_views($dir, $base) {
- elgg_log('get_views() was deprecated in 1.7 by elgg_get_views()!', 'WARNING');
+ elgg_deprecated_notice('get_views() was deprecated by elgg_get_views()!', 1.7);
elgg_get_views($dir, $base);
}
@@ -1112,7 +1112,7 @@ function elgg_extend_view($view, $view_name, $priority = 501, $viewtype = '') {
* @param $viewtype
*/
function extend_view($view, $view_name, $priority = 501, $viewtype = '') {
- elgg_log('extend_view() was deprecated in 1.7 by elgg_extend_view()!', 'WARNING');
+ elgg_deprecated_notice('extend_view() was deprecated by elgg_extend_view()!', 1.7);
elgg_extend_view($view, $view_name, $priority, $viewtype);
}
@@ -2076,6 +2076,55 @@ function run_function_once($functionname, $timelastupdatedcheck = 0) {
}
}
+/**
+ * Sends a notice about deprecated use of a function, view, etc.
+ * Note: This will ALWAYS at least log a warning. Don't use to pre-deprecate things.
+ * This assume we are releasing in order and deprecating according to policy.
+ *
+ * @param str $msg Message to log / display.
+ * @param str $version human-readable *release* version the function was deprecated. No bloody A, B, (R)C, or D.
+ *
+ * @return bool
+ */
+function elgg_deprecated_notice($msg, $dep_version) {
+ // if it's a major release behind, visual and logged
+ // if it's a 2 minor releases behind, visual and logged
+ // if it's 1 minor release behind, logged.
+ // bugfixes don't matter because you're not deprecating between the, RIGHT?
+
+ if (!$dep_version) {
+ return FALSE;
+ }
+
+ $elgg_version = get_version(TRUE);
+ $elgg_version_arr = explode('.', $elgg_version);
+ $elgg_major_version = $elgg_version_arr[0];
+ $elgg_minor_version = $elgg_version_arr[1];
+
+ $dep_version_arr = explode('.', $dep_version);
+ $dep_major_version = $dep_version_arr[0];
+ $dep_minor_version = $dep_version_arr[1];
+
+ $last_working_version = $dep_minor_version - 1;
+
+ $visual = FALSE;
+
+ // use version_compare to account for 1.7a < 1.7
+ if (($dep_major_version < $elgg_major_version)
+ || (($elgg_minor_version - $last_working_version) > 1)) {
+ $visual = TRUE;
+ }
+
+ $msg = "Deprecated in $dep_version: $msg";
+
+ elgg_log($msg, 'WARNING');
+
+ if ($visual) {
+ register_error($msg);
+ }
+
+ return TRUE;
+}
/**