diff options
author | Andreas Gohr <andi@splitbrain.org> | 2014-05-10 15:49:53 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2014-05-10 15:49:53 +0200 |
commit | 1419a485e3ac0c507ef073f0b816bd41f7e4a5cd (patch) | |
tree | 4f3980583bb25a521b44fdd758d60309fd5df477 /inc/infoutils.php | |
parent | 811653d71565cce94ca1b27f4cdebc60769e2d11 (diff) | |
download | rpg-1419a485e3ac0c507ef073f0b816bd41f7e4a5cd.tar.gz rpg-1419a485e3ac0c507ef073f0b816bd41f7e4a5cd.tar.bz2 |
log deprecated function calls FS#2399
This introduces a new dbg_deprecated() function which allows for easy
marking of deprecated functions. Each call is logged to the debuglog
when debuggin is enabled.
Diffstat (limited to 'inc/infoutils.php')
-rw-r--r-- | inc/infoutils.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/inc/infoutils.php b/inc/infoutils.php index 0992040d9..807323715 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -384,6 +384,32 @@ function dbglog($msg,$header=''){ } /** + * Log accesses to deprecated fucntions to the debug log + * + * @param string $alternative The function or method that should be used instead + */ +function dbg_deprecated($alternative = '') { + global $conf; + if(!$conf['allowdebug']) return; + + $backtrace = debug_backtrace(); + array_shift($backtrace); + $self = array_shift($backtrace); + $call = array_shift($backtrace); + + $called = trim($self['class'].'::'.$self['function'].'()', ':'); + $caller = trim($call['class'].'::'.$call['function'].'()', ':'); + + $msg = $called.' is deprecated. It was called from '; + $msg .= $caller.' in '.$call['file'].':'.$call['line']; + if($alternative) { + $msg .= ' '.$alternative.' should be used instead!'; + } + + dbglog($msg); +} + +/** * Print a reversed, prettyprinted backtrace * * @author Gary Owen <gary_owen@bigfoot.com> |