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/infoutils.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'inc/infoutils.php') 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 * -- cgit v1.2.3 From 6164d9001d4b6d300e386db4ed295986c56f0635 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 10 May 2014 15:54:18 +0200 Subject: doc block updates --- inc/infoutils.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index 0992040d9..4faaee8ef 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -280,6 +280,15 @@ define('MSG_USERS_ONLY', 1); define('MSG_MANAGERS_ONLY',2); define('MSG_ADMINS_ONLY',4); +/** + * Display a message to the user + * + * @param string $message + * @param int $lvl -1 = error, 0 = info, 1 = success, 2 = notify + * @param string $line line number + * @param string $file file number + * @param int $allow who's allowed to see the message, see MSG_* constants + */ function msg($message,$lvl=0,$line='',$file='',$allow=MSG_PUBLIC){ global $MSG, $MSG_shown; $errors[-1] = 'error'; @@ -309,6 +318,7 @@ function msg($message,$lvl=0,$line='',$file='',$allow=MSG_PUBLIC){ * lvl => int, level of the message (see msg() function) * allow => int, flag used to determine who is allowed to see the message * see MSG_* constants + * @return bool */ function info_msg_allowed($msg){ global $INFO, $auth; -- cgit v1.2.3 From 8f1efc437b686ec79c258f63e550f7bfec5c2b06 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 15 Aug 2014 11:47:22 +0200 Subject: sanity check update message This should avoid problems when a WiFi login redirect intercepts the update check. See https://forum.dokuwiki.org/post/45076 --- inc/infoutils.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index db856141f..f9ba11560 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -30,7 +30,12 @@ function checkUpdateMessages(){ $http = new DokuHTTPClient(); $http->timeout = 12; $data = $http->get(DOKU_MESSAGEURL.$updateVersion); - io_saveFile($cf,$data); + if(substr(trim($data), -1) != '%') { + // this doesn't look like one of our messages, maybe some WiFi login interferred + $data = ''; + }else { + io_saveFile($cf,$data); + } }else{ dbglog("checkUpdateMessages(): messages.txt up to date"); $data = io_readFile($cf); -- cgit v1.2.3