本文整理汇总了PHP中wfDebugBacktrace函数的典型用法代码示例。如果您正苦于以下问题:PHP wfDebugBacktrace函数的具体用法?PHP wfDebugBacktrace怎么用?PHP wfDebugBacktrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfDebugBacktrace函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfGetAllCallers
/**
* Return a string consisting of callers in the stack. Useful sometimes
* for profiling specific points.
*
* @param int $limit The maximum depth of the stack frame to return, or false for the entire stack.
* @return string
*/
function wfGetAllCallers($limit = 3)
{
$trace = array_reverse(wfDebugBacktrace());
if (!$limit || $limit > count($trace) - 1) {
$limit = count($trace) - 1;
}
$trace = array_slice($trace, -$limit - 1, $limit);
return implode('/', array_map('wfFormatStackFrame', $trace));
}
示例2: getCallerDescription
/**
* Get an array describing the calling function at a specified offset.
*
* @param $callerOffset integer: How far up the callstack is the original
* caller. 0 = function that called getCallerDescription()
* @return array with two keys: 'file' and 'func'
*/
private static function getCallerDescription($callerOffset)
{
$callers = wfDebugBacktrace();
if (isset($callers[$callerOffset])) {
$callerfile = $callers[$callerOffset];
if (isset($callerfile['file']) && isset($callerfile['line'])) {
$file = $callerfile['file'] . ' at line ' . $callerfile['line'];
} else {
$file = '(internal function)';
}
} else {
$file = '(unknown location)';
}
if (isset($callers[$callerOffset + 1])) {
$callerfunc = $callers[$callerOffset + 1];
$func = '';
if (isset($callerfunc['class'])) {
$func .= $callerfunc['class'] . '::';
}
if (isset($callerfunc['function'])) {
$func .= $callerfunc['function'];
}
} else {
$func = 'unknown';
}
return array('file' => $file, 'func' => $func);
}
示例3: getCaller
/**
* Get function caller
*
* @param $level Integer
*/
static function getCaller($level)
{
$backtrace = wfDebugBacktrace();
if (isset($backtrace[$level])) {
if (isset($backtrace[$level]['class'])) {
$caller = $backtrace[$level]['class'] . '::' . $backtrace[$level]['function'];
} else {
$caller = $backtrace[$level]['function'];
}
} else {
$caller = 'unknown';
}
return $caller;
}
示例4: wfWarn
/**
* Send a warning either to the debug log or in a PHP error depending on
* $wgDevelopmentWarnings
*
* @param $msg String: message to send
* @param $callerOffset Integer: number of items to go back in the backtrace to
* find the correct caller (1 = function calling wfWarn, ...)
* @param $level Integer: PHP error level; only used when $wgDevelopmentWarnings
* is true
*/
function wfWarn($msg, $callerOffset = 1, $level = E_USER_NOTICE)
{
global $wgDevelopmentWarnings;
$callers = wfDebugBacktrace();
if (isset($callers[$callerOffset + 1])) {
$callerfunc = $callers[$callerOffset + 1];
$callerfile = $callers[$callerOffset];
if (isset($callerfile['file']) && isset($callerfile['line'])) {
$file = $callerfile['file'] . ' at line ' . $callerfile['line'];
} else {
$file = '(internal function)';
}
$func = '';
if (isset($callerfunc['class'])) {
$func .= $callerfunc['class'] . '::';
}
if (isset($callerfunc['function'])) {
$func .= $callerfunc['function'];
}
$msg .= " [Called from {$func} in {$file}]";
}
if ($wgDevelopmentWarnings) {
trigger_error($msg, $level);
} else {
wfDebug("{$msg}\n");
}
}
示例5: debugBacktrace
/**
* Wikia denug backtrace logger
*
* @example Wikia::debugBacktrace(__METHOD__);
* @author Piotr Molski <moli@wikia-inc.com>
*
* @param String $method - use __METHOD__ as default
*
* @deprecated use WikiaLogger instead
*/
public static function debugBacktrace($method)
{
$backtrace = wfDebugBacktrace();
$msg = "***** BEGIN *****";
Wikia::log($method, false, $msg, true);
foreach ($backtrace as $call) {
$msg = "";
if (isset($call['file'])) {
$f = explode(DIRECTORY_SEPARATOR, $call['file']);
$file = $f[count($f) - 1];
} else {
$file = '-';
}
if (isset($call['line'])) {
$line = $call['line'];
} else {
$line = '-';
}
$msg .= "{$file} line {$line} calls ";
if (!empty($call['class'])) {
$msg .= $call['class'] . '::';
}
$msg .= $call['function'] . '()';
Wikia::log($method, false, $msg, true);
}
$msg = "***** END *****";
Wikia::log($method, false, $msg, true);
}
示例6: __triggerError
/**
* Internal error handler
*
* @internal Internal error handler
* @param string $message Error message
* @param string $file Filename
* @param integer $line Line number
* @param integer $code Error code
* @return void
*/
private static function __triggerError($message, $file, $line, $code = 0, $depthLimit = null)
{
$message = $message . "depth=" . $depthLimit;
wfDebug(print_r(wfDebugBacktrace($depthLimit), true));
if (self::$useExceptions) {
throw new S3Exception($message, $file, $line, $code);
} else {
trigger_error($message, E_USER_WARNING);
}
}
示例7: wfDeprecated
/**
* Throws an E_USER_NOTICE saying that $function is deprecated
* @param string $function
* @return null
*/
function wfDeprecated($function)
{
global $wgDebugLogFile;
if (!$wgDebugLogFile) {
return;
}
$callers = wfDebugBacktrace();
if (isset($callers[2])) {
$callerfunc = $callers[2];
$callerfile = $callers[1];
if (isset($callerfile['file']) && isset($callerfile['line'])) {
$file = $callerfile['file'] . ' at line ' . $callerfile['line'];
} else {
$file = '(internal function)';
}
$func = '';
if (isset($callerfunc['class'])) {
$func .= $callerfunc['class'] . '::';
}
$func .= @$callerfunc['function'];
$msg = "Use of {$function} is deprecated. Called from {$func} in {$file}";
} else {
$msg = "Use of {$function} is deprecated.";
}
wfDebug("{$msg}\n");
}
示例8: wfGetAllCallers
/** Return a string consisting all callers in stack, somewhat useful sometimes for profiling specific points */
function wfGetAllCallers()
{
return implode('/', array_map(create_function('$frame', '
return isset( $frame["class"] )?
$frame["class"]."::".$frame["function"]:
$frame["function"];
'), array_reverse(wfDebugBacktrace())));
}
示例9: markTestSkipped
/**
* Mark this test as skipped. Puts extra information in the logs.
*
* @param string $message
*/
public static function markTestSkipped($message = '')
{
$backtrace = wfDebugBacktrace(3);
$entry = $backtrace[1];
Wikia::log(wfFormatStackFrame($entry), false, "marked as skipped - {$message}");
parent::markTestSkipped($message);
}
示例10: wfGetCallerClassMethod
/**
* Go through the backtrace and return the first method that is not in the ingored class
* @param $ignoreClasses mixed array of ignored class names or a single class name
* @return string method name
*/
function wfGetCallerClassMethod($ignoreClasses)
{
// analyze the backtrace to log the source of purge requests
$backtrace = wfDebugBacktrace();
$method = '';
if (is_string($ignoreClasses)) {
$ignoreClasses = [$ignoreClasses];
}
while ($entry = array_shift($backtrace)) {
if (empty($entry['class']) || in_array($entry['class'], $ignoreClasses)) {
continue;
}
// skip closures
// e.g. "FilePageController:{closure}"
if ($entry['function'] === '{closure}') {
continue;
}
$method = $entry['class'] . ':' . $entry['function'];
break;
}
return $method;
}
示例11: saveSettings
/**
* Save this user's settings into the database.
* @todo Only rarely do all these fields need to be set!
*/
public function saveSettings()
{
global $wgAuth;
$this->load();
if (wfReadOnly()) {
return;
}
if (0 == $this->mId) {
return;
}
$this->mTouched = self::newTouchedTimestamp();
if (!$wgAuth->allowSetLocalPassword()) {
$this->mPassword = '';
}
// wikia change begin
/**
* @author Krzysztof Krzyżaniak (eloy)
* trap for BugId: 4013
*/
if ($this->mEmail == "devbox@wikia-inc.com" || $this->mEmail == "devbox+test@wikia-inc.com") {
// gather everything we know about request
global $wgCommandLineMode;
$log = "MOLI TRAP@devbox: ";
if ($wgCommandLineMode && !empty($argv)) {
$log .= $argv[0];
openlog("trap", LOG_PID | LOG_PERROR, LOG_LOCAL6);
syslog(LOG_WARNING, "{$log}");
closelog();
} else {
global $wgTitle;
if (is_object($wgTitle)) {
$log .= $wgTitle->getFullUrl();
error_log($log);
}
}
}
/**
* @author Michał Roszka (Mix)
* trap for BugId:17012
*/
if ('Lancer1289' == $this->mName) {
$oTo = $oFrom = new MailAddress('mix@wikia-inc.com');
UserMailer::send($oTo, $oFrom, 'BugId:17012 Occurrence Report', serialize(wfDebugBacktrace()));
}
// wikia change end
$dbw = wfGetDB(DB_MASTER);
$dbw->update('user', array('user_name' => $this->mName, 'user_password' => $this->mPassword, 'user_newpassword' => $this->mNewpassword, 'user_newpass_time' => $dbw->timestampOrNull($this->mNewpassTime), 'user_real_name' => $this->mRealName, 'user_email' => $this->mEmail, 'user_email_authenticated' => $dbw->timestampOrNull($this->mEmailAuthenticated), 'user_touched' => $dbw->timestamp($this->mTouched), 'user_token' => strval($this->mToken), 'user_email_token' => $this->mEmailToken, 'user_email_token_expires' => $dbw->timestampOrNull($this->mEmailTokenExpires)), array('user_id' => $this->mId), __METHOD__);
$this->saveOptions();
wfRunHooks('UserSaveSettings', array($this));
$this->clearSharedCache();
# Wikia - bad style fix for #1531 - needs review if it is still needed
global $wgRequest;
$action = $wgRequest->getVal('action');
$commit = isset($action) && $action == 'ajax';
if ($commit === true) {
$dbw->commit();
}
$this->getUserPage()->invalidateCache();
}
示例12: efErrorHandler
/**
* Custom error handler
*
* @param $errType Integer: type of error
* @param $errMsg String: error message
* @param $errFile String: file where the error occured
* @param $errLine Integer: line where the error occured
* @param $errVars Array: hmm?
*/
function efErrorHandler($errType, $errMsg, $errFile, $errLine, $errVars)
{
global $wgErrorHandlerErrors, $wgErrorHandlerOutputDone, $wgErrorHandlerShowBackTrace, $wgErrorHandlerReport, $wgErrorHandlerMaxStringSize, $wgErrorHandlerAlwaysReport, $wgErrorHandlerReportAfterOutput, $wgErrorHandlerLog;
global $IP, $wgCommandLineMode;
static $errorsMap = array(E_ERROR => 'fatal', E_WARNING => 'warning', E_PARSE => 'parse', E_NOTICE => 'notice', E_CORE_ERROR => 'core-error', E_CORE_WARNING => 'core-warning', E_COMPILE_ERROR => 'compile-error', E_COMPILE_WARNING => 'compile-warning', E_USER_ERROR => 'user-error', E_USER_WARNING => 'user-warning', E_USER_NOTICE => 'user-notice', E_STRICT => 'strict', 4096 => 'recoverable', 8192 => 'deprecated', 16384 => 'user-deprecated');
if (!($errType & $wgErrorHandlerReport) || !$wgErrorHandlerAlwaysReport && !(error_reporting() & $errType)) {
return false;
}
$trace = array();
// Show the backtrace
if ($wgErrorHandlerShowBackTrace) {
if (function_exists('wfDebugBacktrace')) {
$backtrace = array_slice(wfDebugBacktrace(), 1);
} else {
$backtrace = array_slice(debug_backtrace(), 1);
}
foreach ($backtrace as $call) {
if (isset($call['file']) && isset($call['line'])) {
$safeIP = preg_quote($IP, '/');
$file = preg_replace("/^{$safeIP}/", '.', $call['file']);
$line = $call['line'];
$internal = false;
} else {
$internal = true;
}
$func = '';
if (!empty($call['class'])) {
$func .= $call['class'] . $call['type'];
}
$func .= $call['function'];
if (isset($call['args']) && !empty($call['args']) && is_array($call['args'])) {
$args = array();
foreach ($call['args'] as $arg) {
if (is_object($arg)) {
$args[] = 'Object(' . get_class($arg) . ')';
} elseif (is_null($arg)) {
$args[] = 'null';
} elseif (is_array($arg)) {
$args[] = 'array()';
} elseif (is_string($arg)) {
if (strlen($arg) > $wgErrorHandlerMaxStringSize) {
$str = substr($arg, 0, $wgErrorHandlerMaxStringSize) . '...';
} else {
$str = $arg;
}
$args[] = '\'' . str_replace("\n", '', $str) . '\'';
} elseif (is_numeric($arg)) {
$args[] = (string) $arg;
} elseif (is_bool($arg)) {
$args[] = 'bool(' . ($arg ? 'true' : 'false') . ')';
} else {
$args[] = gettype($arg) . '(' . $arg . ')';
}
}
$func .= '( ' . implode(', ', $args) . ' )';
} else {
$func .= '()';
}
$func = htmlspecialchars($func);
if ($internal) {
$res = array('errorhandler-trace-line-internal', $func);
} else {
$file = htmlspecialchars($file);
$res = array('errorhandler-trace-line', $file, $line, $func);
}
$trace[] = $res;
}
}
$err = array('error' => 'errorhandler-error-' . $errorsMap[$errType], 'msg' => $errMsg, 'file' => $errFile, 'line' => $errLine, 'trace' => $trace);
$errText = efErrorGetText($err, true);
if ($wgErrorHandlerLog === true) {
error_log($errText, 0);
} elseif (file_exists($wgErrorHandlerLog)) {
error_log($errText, 3, $wgErrorHandlerLog);
}
if ($wgCommandLineMode) {
echo $errText;
} else {
if ($wgErrorHandlerOutputDone) {
if ($wgErrorHandlerReportAfterOutput) {
echo efErrorGetText($err);
} else {
$wgErrorHandlerErrors[] = $err;
}
}
}
return true;
}
示例13: updateUser
public function updateUser()
{
global $wgExternalSharedDB;
wfProfileIn(__METHOD__);
if (wfReadOnly()) {
// Change to wgReadOnlyDbMode if we implement that
wfDebug(__METHOD__ . ": tried to updateUser while in read-only mode.\n");
} else {
wfDebug(__METHOD__ . ": update central user data \n");
/**
* @author Michał Roszka (Mix)
* trap for BugId:17012
*/
if ('Lancer1289' == $this->mUser->mName) {
$oTo = $oFrom = new MailAddress('mix@wikia-inc.com');
UserMailer::send($oTo, $oFrom, 'BugId:17012 Occurrence Report', serialize(wfDebugBacktrace()));
}
$dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
$this->mUser->mTouched = User::newTouchedTimestamp();
$dbw->update('`user`', array('user_name' => $this->mUser->mName, 'user_password' => $this->mUser->mPassword, 'user_newpassword' => $this->mUser->mNewpassword, 'user_newpass_time' => $dbw->timestampOrNull($this->mUser->mNewpassTime), 'user_real_name' => $this->mUser->mRealName, 'user_email' => $this->mUser->mEmail, 'user_email_authenticated' => $dbw->timestampOrNull($this->mUser->mEmailAuthenticated), 'user_options' => '', 'user_touched' => $dbw->timestamp($this->mUser->mTouched), 'user_token' => $this->mUser->mToken, 'user_email_token' => $this->mUser->mEmailToken, 'user_email_token_expires' => $dbw->timestampOrNull($this->mUser->mEmailTokenExpires)), array('user_id' => $this->mUser->mId), __METHOD__);
$dbw->commit();
}
wfProfileOut(__METHOD__);
}
示例14: wfGetAllCallers
/** Return a string consisting all callers in stack, somewhat useful sometimes for profiling specific points */
function wfGetAllCallers()
{
return implode('/', array_map('wfFormatStackFrame', array_reverse(wfDebugBacktrace())));
}