From 1419a485e3ac0c507ef073f0b816bd41f7e4a5cd Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 10 May 2014 15:49:53 +0200 Subject: 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. --- inc/TarLib.class.php | 2 ++ inc/changelog.php | 6 ++++-- inc/infoutils.php | 26 ++++++++++++++++++++++++++ inc/plugin.php | 1 + inc/subscription.php | 1 + 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/inc/TarLib.class.php b/inc/TarLib.class.php index ae08039ec..dd319a79a 100644 --- a/inc/TarLib.class.php +++ b/inc/TarLib.class.php @@ -26,6 +26,8 @@ class TarLib { public $_result = true; function __construct($file, $comptype = TarLib::COMPRESS_AUTO, $complevel = 9) { + dbg_deprecated('class Tar'); + if(!$file) $this->error('__construct', '$file'); $this->file = $file; diff --git a/inc/changelog.php b/inc/changelog.php index de06c9683..f0788d896 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -1004,12 +1004,13 @@ class MediaChangelog extends ChangeLog { * changelog files, only the chunk containing the * requested changelog line is read. * - * @deprecated 20-11-2013 + * @deprecated 2013-11-20 * * @author Ben Coburn * @author Kate Arzamastseva */ function getRevisionInfo($id, $rev, $chunk_size = 8192, $media = false) { + dbg_deprecated('class PageChangeLog or class MediaChanglog'); if($media) { $changelog = new MediaChangeLog($id, $chunk_size); } else { @@ -1036,12 +1037,13 @@ function getRevisionInfo($id, $rev, $chunk_size = 8192, $media = false) { * backwards in chunks until the requested number of changelog * lines are recieved. * - * @deprecated 20-11-2013 + * @deprecated 2013-11-20 * * @author Ben Coburn * @author Kate Arzamastseva */ function getRevisions($id, $first, $num, $chunk_size = 8192, $media = false) { + dbg_deprecated('class PageChangeLog or class MediaChanglog'); if($media) { $changelog = new MediaChangeLog($id, $chunk_size); } else { diff --git a/inc/infoutils.php b/inc/infoutils.php index 0992040d9..807323715 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -383,6 +383,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 * diff --git a/inc/plugin.php b/inc/plugin.php index 7de4fbd74..e0112ef56 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -252,6 +252,7 @@ class DokuWiki_Plugin { */ function __call($name, $arguments) { if($name == 'render'){ + dbg_deprecated('render_text()'); if(!isset($arguments[1])) $arguments[1] = 'xhtml'; return $this->render_text($arguments[0], $arguments[1]); } diff --git a/inc/subscription.php b/inc/subscription.php index 298e7c12b..a6f3dec44 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -700,6 +700,7 @@ class Subscription { * @deprecated 2012-12-07 */ function subscription_addresslist(&$data) { + dbg_deprecated('class Subscription'); $sub = new Subscription(); $sub->notifyaddresses($data); } -- cgit v1.2.3