本文整理汇总了PHP中wfGetCaller函数的典型用法代码示例。如果您正苦于以下问题:PHP wfGetCaller函数的具体用法?PHP wfGetCaller怎么用?PHP wfGetCaller使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfGetCaller函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: intermediateFunction
function intermediateFunction($level = 2, $n = 0)
{
if ($n > 0) {
return self::intermediateFunction($level, $n - 1);
}
return wfGetCaller($level);
}
示例2: Out
/**
* Stop profiling of a processor
*
* @since 1.9
*
* @param string $name name of the function we will profile
* @param boolean $caller if the caller should be profiled as well
*/
public static function Out($name = false, $caller = false)
{
$instance = self::getInstance();
if ($instance instanceof \Profiler) {
$processor = $name ? $name : wfGetCaller(2);
if ($caller) {
$instance->profileOut($processor . '-' . wfGetCaller(3));
}
$instance->profileOut($processor);
}
return $instance;
}
示例3: _unstub
/**
* This is public, for the convenience of external callers wishing to access
* properties, e.g. eval.php
*/
function _unstub($name = '_unstub', $level = 2)
{
static $recursionLevel = 0;
if (get_class($GLOBALS[$this->mGlobal]) != $this->mClass) {
$fname = __METHOD__ . '-' . $this->mGlobal;
wfProfileIn($fname);
$caller = wfGetCaller($level);
if (++$recursionLevel > 2) {
throw new MWException("Unstub loop detected on call of \${$this->mGlobal}->{$name} from {$caller}\n");
}
wfDebug("Unstubbing \${$this->mGlobal} on call of \${$this->mGlobal}->{$name} from {$caller}\n");
$GLOBALS[$this->mGlobal] = $this->_newObject();
--$recursionLevel;
wfProfileOut($fname);
}
}
示例4: decho
function decho($name, $value = "", $html = true)
{
$lineEnd = "<br>\n";
if (!$html) {
$lineEnd = "\n";
}
$prefix = wfGetCaller(2);
if (is_string($value)) {
echo "{$prefix}: {$name}: {$value}";
} else {
if ((!is_array($value) || !is_object($value)) && method_exists($value, '__toString')) {
print_r("{$prefix}: {$name}: {$value}");
} else {
echo "{$prefix}: {$name}: ";
print_r($value);
echo $lineEnd;
}
}
echo $lineEnd;
}
示例5: debug
/**
* Write $msg under log group 'tests-parser'
* @param string $msg Message to log
*/
protected static function debug($msg)
{
return wfDebugLog('tests-parser', wfGetCaller() . ' ' . $msg);
}
示例6: onTransactionPreCommitOrIdle
/**
* Run an anonymous function before the current transaction commits or now if there is none.
* If there is a transaction and it is rolled back, then the callback is cancelled.
* Callbacks must not start nor commit any transactions.
*
* This is useful for updates that easily cause deadlocks if locks are held too long
* but where atomicity is strongly desired for these updates and some related updates.
*
* @param callable $callback
* @since 1.22
*/
final public function onTransactionPreCommitOrIdle( $callback ) {
if ( $this->mTrxLevel ) {
$this->mTrxPreCommitCallbacks[] = array( $callback, wfGetCaller() );
} else {
$this->onTransactionIdle( $callback ); // this will trigger immediately
}
}
示例7: log
/**
* Adds a line to the log
*
* @todo Add support for passing objects
*
* @since 1.19
* @param $str string
*/
public static function log($str)
{
if (!self::$enabled) {
return;
}
self::$log[] = array('msg' => htmlspecialchars($str), 'type' => 'log', 'caller' => wfGetCaller());
}
示例8: _unstub
/**
* This function creates a new object of the real class and replace it in
* the global variable.
* This is public, for the convenience of external callers wishing to access
* properties, e.g. eval.php
*
* @param string $name Name of the method called in this object.
* @param int $level Level to go in the stack trace to get the function
* who called this function.
* @return object The unstubbed version of itself
* @throws MWException
*/
public function _unstub($name = '_unstub', $level = 2)
{
static $recursionLevel = 0;
if (!$GLOBALS[$this->global] instanceof StubObject) {
return $GLOBALS[$this->global];
// already unstubbed.
}
if (get_class($GLOBALS[$this->global]) != $this->class) {
$caller = wfGetCaller($level);
if (++$recursionLevel > 2) {
throw new MWException("Unstub loop detected on call of " . "\${$this->global}->{$name} from {$caller}\n");
}
wfDebug("Unstubbing \${$this->global} on call of " . "\${$this->global}::{$name} from {$caller}\n");
$GLOBALS[$this->global] = $this->_newObject();
--$recursionLevel;
return $GLOBALS[$this->global];
}
}
示例9: save
/** Unless you know what you're doing, you want commitRevision */
function save($fname = null)
{
$this->dieIfHistorical();
$dbr = wfGetDB(DB_MASTER);
if (!$fname) {
$fname = __METHOD__ . "/" . wfGetCaller();
} else {
$fname = __METHOD__ . "/" . $fname;
}
$dbr->update('thread', $this->getRow(), array('thread_id' => $this->id), $fname);
// Touch the root
if ($this->root()) {
$this->root()->getTitle()->invalidateCache();
}
// Touch the talk page, too.
$this->getTitle()->invalidateCache();
$this->dbVersion = clone $this;
unset($this->dbVersion->dbVersion);
}
示例10: parse
/**
* Convert wikitext to HTML
* Do not call this function recursively.
*
* @param $text String: text we want to parse
* @param $title A title object
* @param $options ParserOptions
* @param $linestart boolean
* @param $clearState boolean
* @param $revid Int: number to pass in {{REVISIONID}}
* @return ParserOutput a ParserOutput
*/
public function parse($text, Title $title, ParserOptions $options, $linestart = true, $clearState = true, $revid = null)
{
/**
* First pass--just handle <nowiki> sections, pass the rest off
* to internalParse() which does all the real work.
*/
global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang;
$fname = __METHOD__ . '-' . wfGetCaller();
wfProfileIn(__METHOD__);
wfProfileIn($fname);
if ($clearState) {
$this->clearState();
}
$this->mOptions = $options;
$this->setTitle($title);
$oldRevisionId = $this->mRevisionId;
$oldRevisionTimestamp = $this->mRevisionTimestamp;
if ($revid !== null) {
$this->mRevisionId = $revid;
$this->mRevisionTimestamp = null;
}
$this->setOutputType(self::OT_HTML);
wfRunHooks('ParserBeforeStrip', array(&$this, &$text, &$this->mStripState));
# No more strip!
wfRunHooks('ParserAfterStrip', array(&$this, &$text, &$this->mStripState));
$text = $this->internalParse($text);
$text = $this->mStripState->unstripGeneral($text);
# Clean up special characters, only run once, next-to-last before doBlockLevels
$fixtags = array('/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1 \\2', '/(\\302\\253) /' => '\\1 ', '/ (!\\s*important)/' => ' \\1');
$text = preg_replace(array_keys($fixtags), array_values($fixtags), $text);
$text = $this->doBlockLevels($text, $linestart);
$this->replaceLinkHolders($text);
# the position of the parserConvert() call should not be changed. it
# assumes that the links are all replaced and the only thing left
# is the <nowiki> mark.
# Side-effects: this calls $this->mOutput->setTitleText()
$text = $wgContLang->parserConvert($text, $this);
$text = $this->mStripState->unstripNoWiki($text);
wfRunHooks('ParserBeforeTidy', array(&$this, &$text));
//!JF Move to its own function
$uniq_prefix = $this->mUniqPrefix;
$matches = array();
$elements = array_keys($this->mTransparentTagHooks);
$text = self::extractTagsAndParams($elements, $text, $matches, $uniq_prefix);
foreach ($matches as $marker => $data) {
list($element, $content, $params, $tag) = $data;
$tagName = strtolower($element);
if (isset($this->mTransparentTagHooks[$tagName])) {
$output = call_user_func_array($this->mTransparentTagHooks[$tagName], array($content, $params, $this));
} else {
$output = $tag;
}
$this->mStripState->general->setPair($marker, $output);
}
$text = $this->mStripState->unstripGeneral($text);
$text = Sanitizer::normalizeCharReferences($text);
if ($wgUseTidy && $this->mOptions->mTidy || $wgAlwaysUseTidy) {
$text = MWTidy::tidy($text);
} else {
# attempt to sanitize at least some nesting problems
# (bug #2702 and quite a few others)
$tidyregs = array('/(<([bi])>)(<([bi])>)?([^<]*)(<\\/?a[^<]*>)([^<]*)(<\\/\\4>)?(<\\/\\2>)/' => '\\1\\3\\5\\8\\9\\6\\1\\3\\7\\8\\9', '/(<a[^>]+>)([^<]*)(<a[^>]+>[^<]*)<\\/a>(.*)<\\/a>/' => '\\1\\2</a>\\3</a>\\1\\4</a>', '/(<([aib]) [^>]+>)([^<]*)(<div([^>]*)>)(.*)(<\\/div>)([^<]*)(<\\/\\2>)/' => '\\1\\3<div\\5>\\6</div>\\8\\9', '/<([bi])><\\/\\1>/' => '');
$text = preg_replace(array_keys($tidyregs), array_values($tidyregs), $text);
}
global $wgExpensiveParserFunctionLimit;
if ($this->mExpensiveFunctionCount > $wgExpensiveParserFunctionLimit) {
$this->limitationWarn('expensive-parserfunction', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit);
}
wfRunHooks('ParserAfterTidy', array(&$this, &$text));
# Information on include size limits, for the benefit of users who try to skirt them
if ($this->mOptions->getEnableLimitReport()) {
global $wgExpensiveParserFunctionLimit;
$max = $this->mOptions->getMaxIncludeSize();
$PFreport = "Expensive parser function count: {$this->mExpensiveFunctionCount}/{$wgExpensiveParserFunctionLimit}\n";
$limitReport = "NewPP limit report\n" . "Preprocessor node count: {$this->mPPNodeCount}/{$this->mOptions->mMaxPPNodeCount}\n" . "Post-expand include size: {$this->mIncludeSizes['post-expand']}/{$max} bytes\n" . "Template argument size: {$this->mIncludeSizes['arg']}/{$max} bytes\n" . $PFreport;
wfRunHooks('ParserLimitReport', array($this, &$limitReport));
$text .= "\n<!-- \n{$limitReport}-->\n";
}
$this->mOutput->setText($text);
$this->mRevisionId = $oldRevisionId;
$this->mRevisionTimestamp = $oldRevisionTimestamp;
wfProfileOut($fname);
wfProfileOut(__METHOD__);
return $this->mOutput;
}
示例11: debug
/** Poor man debugging */
protected function debug($msg = '')
{
wfDebug(wfGetCaller() . "{$msg}\n");
}
示例12: parse
/**
* Convert wikitext to HTML
* Do not call this function recursively.
*
* @private
* @param string $text Text we want to parse
* @param Title &$title A title object
* @param array $options
* @param boolean $linestart
* @param boolean $clearState
* @param int $revid number to pass in {{REVISIONID}}
* @return ParserOutput a ParserOutput
*/
function parse($text, &$title, $options, $linestart = true, $clearState = true, $revid = null)
{
/**
* First pass--just handle <nowiki> sections, pass the rest off
* to internalParse() which does all the real work.
*/
global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang;
$fname = 'Parser::parse-' . wfGetCaller();
wfProfileIn($fname);
if ($clearState) {
$this->clearState();
}
$this->mOptions = $options;
$this->mTitle =& $title;
$oldRevisionId = $this->mRevisionId;
if ($revid !== null) {
$this->mRevisionId = $revid;
}
$this->setOutputType(OT_HTML);
//$text = $this->strip( $text, $this->mStripState );
// VOODOO MAGIC FIX! Sometimes the above segfaults in PHP5.
$x =& $this->mStripState;
wfRunHooks('ParserBeforeStrip', array(&$this, &$text, &$x));
$text = $this->strip($text, $x);
wfRunHooks('ParserAfterStrip', array(&$this, &$text, &$x));
$text = $this->internalParse($text);
$text = $this->unstrip($text, $this->mStripState);
# Clean up special characters, only run once, next-to-last before doBlockLevels
$fixtags = array('/(.) (?=\\?|:|;|!|\\302\\273)/' => '\\1 \\2', '/(\\302\\253) /' => '\\1 ');
$text = preg_replace(array_keys($fixtags), array_values($fixtags), $text);
# only once and last
$text = $this->doBlockLevels($text, $linestart);
$this->replaceLinkHolders($text);
# the position of the parserConvert() call should not be changed. it
# assumes that the links are all replaced and the only thing left
# is the <nowiki> mark.
# Side-effects: this calls $this->mOutput->setTitleText()
$text = $wgContLang->parserConvert($text, $this);
$text = $this->unstripNoWiki($text, $this->mStripState);
wfRunHooks('ParserBeforeTidy', array(&$this, &$text));
$text = Sanitizer::normalizeCharReferences($text);
if ($wgUseTidy and $this->mOptions->mTidy or $wgAlwaysUseTidy) {
$text = Parser::tidy($text);
} else {
# attempt to sanitize at least some nesting problems
# (bug #2702 and quite a few others)
$tidyregs = array('/(<([bi])>)(<([bi])>)?([^<]*)(<\\/?a[^<]*>)([^<]*)(<\\/\\4>)?(<\\/\\2>)/' => '\\1\\3\\5\\8\\9\\6\\1\\3\\7\\8\\9', '/(<a[^>]+>)([^<]*)(<a[^>]+>[^<]*)<\\/a>(.*)<\\/a>/' => '\\1\\2</a>\\3</a>\\1\\4</a>', '/(<([aib]) [^>]+>)([^<]*)(<div([^>]*)>)(.*)(<\\/div>)([^<]*)(<\\/\\2>)/' => '\\1\\3<div\\5>\\6</div>\\8\\9', '/<([bi])><\\/\\1>/' => '');
$text = preg_replace(array_keys($tidyregs), array_values($tidyregs), $text);
}
wfRunHooks('ParserAfterTidy', array(&$this, &$text));
# Information on include size limits, for the benefit of users who try to skirt them
if (max($this->mIncludeSizes) > 1000) {
$max = $this->mOptions->getMaxIncludeSize();
$text .= "<!-- \n" . "Pre-expand include size: {$this->mIncludeSizes['pre-expand']} bytes\n" . "Post-expand include size: {$this->mIncludeSizes['post-expand']} bytes\n" . "Template argument size: {$this->mIncludeSizes['arg']} bytes\n" . "Maximum: {$max} bytes\n" . "-->\n";
}
$this->mOutput->setText($text);
$this->mRevisionId = $oldRevisionId;
wfProfileOut($fname);
return $this->mOutput;
}
示例13: deprecated
/**
* Adds a depreciation entry to the log, along with a backtrace
*
* @param $function
* @param $version
* @param $component
* @return mixed
*/
public static function deprecated($function, $version, $component)
{
if (!self::$enabled) {
return;
}
// Chain: This function -> wfDeprecated -> deprecatedFunction -> caller
$caller = wfGetCaller(4);
// Check to see if there already was a warning about this function
$functionString = "{$function}-{$caller}";
if (in_array($functionString, self::$deprecationWarnings)) {
return;
}
$version = $version === false ? '(unknown version)' : $version;
$component = $component === false ? 'MediaWiki' : $component;
$msg = htmlspecialchars("Use of function {$function} was deprecated in {$component} {$version}");
$msg .= Html::rawElement('div', array('class' => 'mw-debug-backtrace'), Html::element('span', array(), 'Backtrace:') . wfBacktrace());
self::$deprecationWarnings[] = $functionString;
self::$log[] = array('msg' => $msg, 'type' => 'deprecated', 'caller' => $caller);
}
示例14: log
/**
* Adds a line to the log
*
* @since 1.19
* @param mixed $str
*/
public static function log($str)
{
if (!self::$enabled) {
return;
}
if (!is_string($str)) {
$str = print_r($str, true);
}
self::$log[] = ['msg' => htmlspecialchars($str), 'type' => 'log', 'caller' => wfGetCaller()];
}
示例15: assertSelect
/**
* Asserts that the given database query yields the rows given by $expectedRows.
* The expected rows should be given as indexed (not associative) arrays, with
* the values given in the order of the columns in the $fields parameter.
* Note that the rows are sorted by the columns given in $fields.
*
* @since 1.20
*
* @param string|array $table The table(s) to query
* @param string|array $fields The columns to include in the result (and to sort by)
* @param string|array $condition "where" condition(s)
* @param array $expectedRows An array of arrays giving the expected rows.
*
* @throws MWException If this test cases's needsDB() method doesn't return true.
* Test cases can use "@group Database" to enable database test support,
* or list the tables under testing in $this->tablesUsed, or override the
* needsDB() method.
*/
protected function assertSelect($table, $fields, $condition, array $expectedRows)
{
if (!$this->needsDB()) {
throw new MWException('When testing database state, the test cases\'s needDB()' . ' method should return true. Use @group Database or $this->tablesUsed.');
}
$db = wfGetDB(DB_SLAVE);
$res = $db->select($table, $fields, $condition, wfGetCaller(), array('ORDER BY' => $fields));
$this->assertNotEmpty($res, "query failed: " . $db->lastError());
$i = 0;
foreach ($expectedRows as $expected) {
$r = $res->fetchRow();
self::stripStringKeys($r);
$i += 1;
$this->assertNotEmpty($r, "row #{$i} missing");
$this->assertEquals($expected, $r, "row #{$i} mismatches");
}
$r = $res->fetchRow();
self::stripStringKeys($r);
$this->assertFalse($r, "found extra row (after #{$i})");
}