当前位置: 首页>>代码示例>>PHP>>正文


PHP wfBacktrace函数代码示例

本文整理汇总了PHP中wfBacktrace函数的典型用法代码示例。如果您正苦于以下问题:PHP wfBacktrace函数的具体用法?PHP wfBacktrace怎么用?PHP wfBacktrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wfBacktrace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: recursiveParseArray

function recursiveParseArray($array)
{
    static $recurseLevel = 0;
    $recurseLevel++;
    if ($recurseLevel > 90) {
        print var_dump($array);
        die(wfBacktrace());
    }
    global $subject, $rootPost;
    if (is_array($array) && isset($array['title'])) {
        $subject = $array['title'];
        recursiveParseArray($array['content']);
        $rootPost = null;
    } elseif (is_array($array) && isset($array['user'])) {
        // We have a post.
        $t = createPost($array, $subject, $rootPost);
        if (!$rootPost) {
            $rootPost = $t;
        }
    } elseif (is_array($array)) {
        foreach ($array as $info) {
            recursiveParseArray($info);
        }
        $rootPost = null;
    }
    $recurseLevel--;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:27,代码来源:import-parsed-discussions.php

示例2: wfCheckPAD

function wfCheckPAD($url, $pad)
{
    global $wgServer, $wgTitle, $wgCookieDomain;
    if ($wgServer == "http://testers.wikihow.com") {
        return true;
    }
    if (($wgServer == "http://www.wikihow.com" || strpos(wfHostname(), "wikihow.com") !== false) && strpos($pad, "whstatic") === false) {
        $alerts = new MailAddress("alerts@wikihow.com");
        // format of date to correspond to varnish file 04/Dec/2010:07:19:06 -0800
        $now = date("d/M/Y:h:i:s O");
        $subject = "Not using PAD for thumbnail on " . wfHostname() . " - " . $now;
        $body = "article {$wgTitle->getFullURL()}\n\n\nUrl: {$url} \n\n \npad {$pad} \n\n\nserver variables " . print_r($_SERVER, true) . "\n\n allheaders: " . print_r(getallheaders(), true) . "\n\n wgserver {$wgServer}\n\ncookie domain {$wgCookieDomain}\n\n Title " . print_r($wgTitle, true) . "\n\nbacktrace: " . strip_tags(wfBacktrace());
        UserMailer::send($alerts, $alerts, $subject, $body, $alerts);
        error_log($body);
        wfDebug($body);
    }
    return true;
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:18,代码来源:Vanilla.php

示例3: logBacktrace

 /**
  * Simple one line backtrace logger
  *
  * @example Wikia::logBacktrace(__METHOD__);
  * @author Maciej Brencz <macbre@wikia-inc.com>
  *
  * @param String $method - use __METHOD__
  *
  * @deprecated use WikiaLogger instead
  */
 public static function logBacktrace($method)
 {
     $backtrace = trim(strip_tags(wfBacktrace()));
     $message = str_replace("\n", '/', $backtrace);
     // add URL when logging from AJAX requests
     if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'GET' && $_SERVER['SCRIPT_URL'] === '/wikia.php') {
         $message .= " URL: {$_SERVER['REQUEST_URI']}";
     }
     Wikia::log($method, false, $message, true);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:20,代码来源:Wikia.php

示例4: skippedNamespace

 private function skippedNamespace($obj)
 {
     if ($obj instanceof Title) {
         $ns = $obj->getNamespace();
     } elseif ($obj instanceof Revision) {
         $ns = $obj->getTitle()->getNamespace();
     } elseif ($obj instanceof WikiRevision) {
         $ns = $obj->title->getNamespace();
     } else {
         echo wfBacktrace();
         $this->error("Cannot get namespace of object in " . __METHOD__, true);
     }
     return is_array($this->nsFilter) && !in_array($ns, $this->nsFilter);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:14,代码来源:importDump.php

示例5: reportExpectationViolated

 /**
  * @param string $expect
  * @param string $query
  */
 protected function reportExpectationViolated($expect, $query)
 {
     global $wgRequest;
     $n = $this->expect[$expect];
     $by = $this->expectBy[$expect];
     $this->logger->info("[{$wgRequest->getMethod()}] Expectation ({$expect} <= {$n}) by {$by} not met:\n{$query}\n" . wfBacktrace(true));
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:11,代码来源:TransactionProfiler.php

示例6: query


//.........这里部分代码省略.........
             $queryProf = 'query: ' . substr(Database::generalizeSQL($sql), 0, 255);
             $totalProf = 'Database::query';
         } else {
             $queryProf = 'query-m: ' . substr(Database::generalizeSQL($sql), 0, 255);
             $totalProf = 'Database::query-master';
         }
         wfProfileIn($totalProf);
         wfProfileIn($queryProf);
     }
     $this->mLastQuery = $sql;
     # Add a comment for easy SHOW PROCESSLIST interpretation
     #if ( $fname ) {
     global $wgUser;
     if (is_object($wgUser) && !$wgUser instanceof StubObject) {
         $userName = $wgUser->getName();
         if (mb_strlen($userName) > 15) {
             $userName = mb_substr($userName, 0, 15) . '...';
         }
         $userName = str_replace('/', '', $userName);
     } else {
         $userName = '';
     }
     $commentedSql = preg_replace('/\\s/', " /* {$fname} {$userName} */ ", $sql, 1);
     #} else {
     #	$commentedSql = $sql;
     #}
     # If DBO_TRX is set, start a transaction
     if ($this->mFlags & DBO_TRX && !$this->trxLevel() && $sql != 'BEGIN' && $sql != 'COMMIT' && $sql != 'ROLLBACK') {
         // avoid establishing transactions for SHOW and SET statements too -
         // that would delay transaction initializations to once connection
         // is really used by application
         $sqlstart = substr($sql, 0, 10);
         // very much worth it, benchmark certified(tm)
         if (strpos($sqlstart, "SHOW ") !== 0 and strpos($sqlstart, "SET ") !== 0) {
             $this->begin();
         }
     }
     if ($this->debug()) {
         $sqlx = substr($commentedSql, 0, 500);
         $sqlx = strtr($sqlx, "\t\n", '  ');
         wfDebug("SQL: {$sqlx}\n");
     }
     # Do the query and handle errors
     $ret = $this->doQuery($commentedSql);
     # Try reconnecting if the connection was lost
     if (false === $ret && ($this->lastErrno() == 2013 || $this->lastErrno() == 2006)) {
         # Transaction is gone, like it or not
         $this->mTrxLevel = 0;
         wfDebug("Connection lost, reconnecting...\n");
         if ($this->ping()) {
             wfDebug("Reconnected\n");
             $sqlx = substr($commentedSql, 0, 500);
             $sqlx = strtr($sqlx, "\t\n", '  ');
             global $wgRequestTime;
             $elapsed = round(microtime(true) - $wgRequestTime, 3);
             wfLogDBError("Connection lost and reconnected after {$elapsed}s, query: {$sqlx}\n");
             $ret = $this->doQuery($commentedSql);
         } else {
             wfDebug("Failed\n");
         }
         // XXCHANGED -- Reuben hack: we've found that our database drivers timeout
         // after 10 minutes of inactivity in a long-running script. We've found that
         // the mysql_ping() that's called right now doesn't work to reconnect, but
         // that closing and re-opening the connection usually works.
         if (false === $ret && $this->lastErrno() == 2006) {
             error_log('Encountered Reuben MySQL error 2006 DB hack. Re-connecting to server ' . $this->mServer);
             @$this->close();
             $this->mConn = null;
             $this->open($this->mServer, $this->mUser, $this->mPassword, $this->mDBname);
             $this->ping();
             $ret = $this->doQuery($commentedSql);
         }
     }
     if (false === $ret) {
         $this->reportQueryError($this->lastError(), $this->lastErrno(), $sql, $fname, $tempIgnore);
     }
     if (!defined('IS_PROD_EN_SITE')) {
         define('IS_PROD_EN_SITE', true);
     }
     if (!$wgCommandLineMode && IS_PROD_EN_SITE && $LOG_SLOW > 0) {
         $total = microtime(true) - $startTime;
         if ($total >= $LOG_SLOW) {
             $prof = substr($sql, 0, 1000);
             $totalStr = sprintf('%.2f', $total) . 's';
             $backtrace = wfBacktrace();
             $hostname = gethostname();
             if (strpos($hostname, 'spare') === false) {
                 $msg = "This query took {$totalStr}:<br>\n<br>\n{$prof}<br>\n<br>\n{$backtrace}<br>\nGenerated on {$hostname}<br>\n";
                 $headers = 'MIME-Version: 1.0' . "\r\n";
                 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                 mail('reuben@wikihow.com,jordan@wikihow.com', 'Slow query: ' . $totalStr, $msg, $headers);
             }
         }
     }
     if ($wgProfiling) {
         wfProfileOut($queryProf);
         wfProfileOut($totalProf);
     }
     return $this->resultObject($ret);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:101,代码来源:Database.php

示例7: wfGetIP

/**
 * Work out the IP address based on various globals
 * For trusted proxies, use the XFF client IP (first of the chain)
 * @return string
 */
function wfGetIP()
{
    global $wgIP;
    # Return cached result
    if (!empty($wgIP)) {
        return $wgIP;
    }
    /* collect the originating ips */
    # Client connecting to this webserver
    if (isset($_SERVER['REMOTE_ADDR'])) {
        $ipchain = array(IP::canonicalize($_SERVER['REMOTE_ADDR']));
    } else {
        # Running on CLI?
        $ipchain = array('127.0.0.1');
    }
    $ip = $ipchain[0];
    # Append XFF on to $ipchain
    $forwardedFor = wfGetForwardedFor();
    if (isset($forwardedFor)) {
        $xff = array_map('trim', explode(',', $forwardedFor));
        $xff = array_reverse($xff);
        $ipchain = array_merge($ipchain, $xff);
    }
    # Step through XFF list and find the last address in the list which is a trusted server
    # Set $ip to the IP address given by that trusted server, unless the address is not sensible (e.g. private)
    foreach ($ipchain as $i => $curIP) {
        $curIP = IP::canonicalize($curIP);
        if (wfIsTrustedProxy($curIP)) {
            if (isset($ipchain[$i + 1]) && IP::isPublic($ipchain[$i + 1])) {
                $ip = $ipchain[$i + 1];
            }
        } else {
            break;
        }
    }
    if (strpos($ip, "192.168.100") !== false) {
        $msg = "wfGetIP: Bad IP {$ip} " . print_r($_SERVER, true) . print_r($wgUser, true) . wfBacktrace() . "\n";
        wfDebug($msg);
    }
    wfDebug("IP: {$ip}\n");
    $wgIP = $ip;
    return $ip;
}
开发者ID:ErdemA,项目名称:wikihow,代码行数:48,代码来源:ProxyTools.php

示例8: reallyOpenConnection

 /**
  * Really opens a connection. Uncached.
  * Returns a Database object whether or not the connection was successful.
  * @access private
  *
  * @param array $server
  * @param bool $dbNameOverride
  * @throws MWException
  * @return DatabaseBase
  */
 protected function reallyOpenConnection($server, $dbNameOverride = false)
 {
     if (!is_array($server)) {
         throw new MWException('You must update your load-balancing configuration. ' . 'See DefaultSettings.php entry for $wgDBservers.');
     }
     if ($dbNameOverride !== false) {
         $server['dbname'] = $dbNameOverride;
     }
     // Log when many connection are made on requests
     if (++$this->connsOpened >= self::CONN_HELD_WARN_THRESHOLD) {
         $masterAddr = $this->getServerName(0);
         wfDebugLog('DBPerformance', __METHOD__ . ": " . "{$this->connsOpened}+ connections made (master={$masterAddr})\n" . wfBacktrace(true));
     }
     # Create object
     try {
         $db = DatabaseBase::factory($server['type'], $server);
     } catch (DBConnectionError $e) {
         // FIXME: This is probably the ugliest thing I have ever done to
         // PHP. I'm half-expecting it to segfault, just out of disgust. -- TS
         $db = $e->db;
     }
     $db->setLBInfo($server);
     if (isset($server['fakeSlaveLag'])) {
         $db->setFakeSlaveLag($server['fakeSlaveLag']);
     }
     if (isset($server['fakeMaster'])) {
         $db->setFakeMaster(true);
     }
     return $db;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:40,代码来源:LoadBalancer.php

示例9: deprecated

 /**
  * Show a warning that $function is deprecated.
  * This will send it to the following locations:
  * - Debug toolbar, with one item per function and caller, if $wgDebugToolbar
  *   is set to true.
  * - PHP's error log, with level E_USER_DEPRECATED, if $wgDevelopmentWarnings
  *   is set to true.
  * - MediaWiki's debug log, if $wgDevelopmentWarnings is set to false.
  *
  * @since 1.19
  * @param string $function Function that is deprecated.
  * @param string|bool $version Version in which the function was deprecated.
  * @param string|bool $component Component to which the function belongs.
  *     If false, it is assumbed the function is in MediaWiki core.
  * @param $callerOffset integer: How far up the callstack is the original
  *    caller. 2 = function that called the function that called
  *    MWDebug::deprecated() (Added in 1.20).
  * @return mixed
  */
 public static function deprecated($function, $version = false, $component = false, $callerOffset = 2)
 {
     $callerDescription = self::getCallerDescription($callerOffset);
     $callerFunc = $callerDescription['func'];
     $sendToLog = true;
     // Check to see if there already was a warning about this function
     if (isset(self::$deprecationWarnings[$function][$callerFunc])) {
         return;
     } elseif (isset(self::$deprecationWarnings[$function])) {
         if (self::$enabled) {
             $sendToLog = false;
         } else {
             return;
         }
     }
     self::$deprecationWarnings[$function][$callerFunc] = true;
     if ($version) {
         global $wgDeprecationReleaseLimit;
         if ($wgDeprecationReleaseLimit && $component === false) {
             # Strip -* off the end of $version so that branches can use the
             # format #.##-branchname to avoid issues if the branch is merged into
             # a version of MediaWiki later than what it was branched from
             $comparableVersion = preg_replace('/-.*$/', '', $version);
             # If the comparableVersion is larger than our release limit then
             # skip the warning message for the deprecation
             if (version_compare($wgDeprecationReleaseLimit, $comparableVersion, '<')) {
                 $sendToLog = false;
             }
         }
         $component = $component === false ? 'MediaWiki' : $component;
         $msg = "Use of {$function} was deprecated in {$component} {$version}.";
     } else {
         $msg = "Use of {$function} is deprecated.";
     }
     if ($sendToLog) {
         global $wgDevelopmentWarnings;
         // we could have a more specific $wgDeprecationWarnings setting.
         self::sendMessage($msg, $callerDescription, 'deprecated', $wgDevelopmentWarnings ? E_USER_DEPRECATED : false);
     }
     if (self::$enabled) {
         $logMsg = htmlspecialchars($msg) . Html::rawElement('div', array('class' => 'mw-debug-backtrace'), Html::element('span', array(), 'Backtrace:') . wfBacktrace());
         self::$log[] = array('msg' => $logMsg, 'type' => 'deprecated', 'caller' => $callerFunc);
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:63,代码来源:Debug.php

示例10: wfDebugDieBacktrace

/**
 * Die with a backtrace
 * This is meant as a debugging aid to track down where bad data comes from.
 * Shouldn't be used in production code except maybe in "shouldn't happen" areas.
 *
 * @param string $msg Message shown when dieing.
 */
function wfDebugDieBacktrace($msg = '')
{
    global $wgCommandLineMode;
    $backtrace = wfBacktrace();
    if ($backtrace !== false) {
        if ($wgCommandLineMode) {
            $msg .= "\nBacktrace:\n{$backtrace}";
        } else {
            $msg .= "\n<p>Backtrace:</p>\n{$backtrace}";
        }
    }
    echo $msg;
    die(-1);
}
开发者ID:BackupTheBerlios,项目名称:enotifwiki,代码行数:21,代码来源:GlobalFunctions.php

示例11: getLength

 /**
  * What is the length of this page?
  * Uses link cache, adding it if necessary
  *
  * @param $flags Int a bit field; may be Title::GAID_FOR_UPDATE to select for update
  * @return Int
  */
 public function getLength($flags = 0)
 {
     if ($this->mLength != -1) {
         return $this->mLength;
     }
     # Calling getArticleID() loads the field from cache as needed
     if (!$this->getArticleID($flags)) {
         return $this->mLength = 0;
     }
     $linkCache = LinkCache::singleton();
     $cached = $linkCache->getGoodLinkFieldObj($this, 'length');
     if ($cached === null) {
         # check the assumption that the cache actually knows about this title
         # XXX: this does apparently happen, see https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
         #      as a stop gap, perhaps log this, but don't throw an exception?
         wfDebug("LinkCache doesn't currently know about this title: " . $this->getPrefixedDBkey());
         wfDebug(wfBacktrace());
     }
     $this->mLength = intval($cached);
     return $this->mLength;
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:28,代码来源:Title.php

示例12: invalidateIDs

 /**
  * Invalidate a set of IDs, right now
  */
 function invalidateIDs(ResultWrapper $res)
 {
     global $wgUseFileCache, $wgUseSquid;
     if ($res->numRows() == 0) {
         return;
     }
     $dbw = wfGetDB(DB_MASTER);
     $timestamp = $dbw->timestamp();
     $done = false;
     while (!$done) {
         # Get all IDs in this query into an array
         $ids = array();
         for ($i = 0; $i < $this->mRowsPerQuery; $i++) {
             $row = $res->fetchRow();
             if ($row) {
                 $ids[] = $row[0];
             } else {
                 $done = true;
                 break;
             }
         }
         if (!count($ids)) {
             break;
         }
         # Update page_touched
         $dbw->update('page', array('page_touched' => $timestamp), array('page_id IN (' . $dbw->makeList($ids) . ')'), __METHOD__);
         wfDebug(date("r") . " PURGE invalidng ids " . print_r($ids, true) . "\n");
         wfDebug(wfBacktrace());
         # Update squid
         if ($wgUseSquid || $wgUseFileCache) {
             $titles = Title::newFromIDs($ids);
             if ($wgUseSquid) {
                 $u = SquidUpdate::newFromTitles($titles);
                 $u->doUpdate();
             }
             # Update file cache
             if ($wgUseFileCache) {
                 foreach ($titles as $title) {
                     $cm = new HTMLFileCache($title);
                     @unlink($cm->fileCacheName());
                 }
             }
         }
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:48,代码来源:HTMLCacheUpdate.php

示例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);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:Debug.php

示例14: editToken

 /**
  * Initialize (if necessary) and return a session token value
  * which can be used in edit forms to show that the user's
  * login credentials aren't being hijacked with a foreign form
  * submission.
  *
  * @param mixed $salt - Optional function-specific data for hash.
  *                      Use a string or an array of strings.
  * @return string
  * @public
  */
 function editToken($salt = '')
 {
     if ($this->isAnon()) {
         return EDIT_TOKEN_SUFFIX;
     } else {
         if (!isset($_SESSION['wsEditToken'])) {
             $token = $this->generateToken();
             $_SESSION['wsEditToken'] = $token;
             // debug
             $_SESSION['wsEditToken_set'] = wfTimestampNow();
             $_SESSION['wsEditToken_hostname'] = wfHostname();
             $_SESSION['wsEditToken_debug'] = "Hostname:\n" . wfHostname() . "\nSession ID: " . session_id() . "\nGET:\n" . print_r($_GET, true) . "\nPOST:\n" . print_r($_POST, true) . "\n" . wfBacktrace();
         } else {
             $token = $_SESSION['wsEditToken'];
         }
         if (is_array($salt)) {
             $salt = implode('|', $salt);
         }
         return md5($token . $salt) . EDIT_TOKEN_SUFFIX;
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:32,代码来源:User.php

示例15: newLanguageAwareRenderer

 /**
  * @param Language|StubUserLang $language
  * @param UsageAccumulator $usageAccumulator
  *
  * @return LanguageAwareRenderer
  * @throws MWException
  */
 private function newLanguageAwareRenderer($language, UsageAccumulator $usageAccumulator)
 {
     if (!$language instanceof Language) {
         wfDebugLog('T107711', get_class($language) . ' is not a Language object.', 'all', array('trace' => wfBacktrace(true)));
     }
     StubUserLang::unstub($language);
     $entityStatementsRenderer = new StatementTransclusionInteractor($language, $this->propertyIdResolver, $this->snaksFinder, $this->newSnakFormatterForLanguage($language, $usageAccumulator), $this->entityLookup);
     return new LanguageAwareRenderer($language, $entityStatementsRenderer);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:16,代码来源:StatementGroupRendererFactory.php


注:本文中的wfBacktrace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。