aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-22 21:14:28 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-22 21:14:28 +0000
commite156208e9d7661aa433abee8e261ed8a9a9749fa (patch)
tree27af6c6c6df4de1b712713b7db21a0814c7192e9 /engine
parente16d25be93c835056a88f91022c9f8d71508d170 (diff)
downloadelgg-e156208e9d7661aa433abee8e261ed8a9a9749fa.tar.gz
elgg-e156208e9d7661aa433abee8e261ed8a9a9749fa.tar.bz2
Added 3rd param to elgg_deprecated_notice() to control how much of the stack to show.
git-svn-id: http://code.elgg.org/elgg/trunk@9014 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/elgglib.php30
1 files changed, 25 insertions, 5 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index e9172d184..8967d9c6c 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -1152,13 +1152,16 @@ function elgg_dump($value, $to_screen = TRUE, $level = 'NOTICE') {
*
* @see CODING.txt
*
- * @param str $msg Message to log / display.
- * @param str $dep_version Human-readable *release* version: 1.7, 1.7.3
+ * @param str $msg Message to log / display.
+ * @param str $dep_version Human-readable *release* version: 1.7, 1.7.3
+ * @param int $backtrace_level How many levels back to display the backtrace. Useful if calling from
+ * functions that are called from other places (like elgg_view()). Set
+ * to -1 for a full backtrace.
*
* @return bool
* @since 1.7.0
*/
-function elgg_deprecated_notice($msg, $dep_version) {
+function elgg_deprecated_notice($msg, $dep_version, $backtrace_level = 1) {
// if it's a major release behind, visual and logged
// if it's a 1 minor release behind, visual and logged
// if it's for current minor release, logged.
@@ -1192,9 +1195,26 @@ function elgg_deprecated_notice($msg, $dep_version) {
// Get a file and line number for the log. Never show this in the UI.
// Skip over the function that sent this notice and see who called the deprecated
// function itself.
+ $msg .= " Called from ";
+ $stack = array();
$backtrace = debug_backtrace();
- $caller = $backtrace[1];
- $msg .= " (Called from {$caller['file']}:{$caller['line']})";
+ // never show this call.
+ array_shift($backtrace);
+ $i = count($backtrace);
+
+ foreach ($backtrace as $trace) {
+ $stack[] = "[#$i] {$trace['file']}:{$trace['line']}";
+ $i--;
+
+ if ($backtrace_level > 0) {
+ if ($backtrace_level <= 1) {
+ break;
+ }
+ $backtrace_level--;
+ }
+ }
+
+ $msg .= implode("<br /> -> ", $stack);
elgg_log($msg, 'WARNING');