• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MWDebug类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testAvoidNonConsecutivesDuplicateDeprecations

 /**
  * @covers MWDebug::deprecated
  */
 public function testAvoidNonConsecutivesDuplicateDeprecations()
 {
     MWDebug::deprecated('wfOldFunction', '1.0', 'component');
     MWDebug::warning('some warning');
     MWDebug::log('we could have logged something too');
     // Another deprecation
     MWDebug::deprecated('wfOldFunction', '1.0', 'component');
     // assertCount() not available on WMF integration server
     $this->assertEquals(3, count(MWDebug::getLog()), "Only one deprecated warning per function should be kept");
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:13,代码来源:MWDebugTest.php


示例2: getClient

 /**
  * Acquire a Redis connection.
  *
  * @access	protected
  * @param	string	[Optiona] Server group key. 
  * 					Example: 'cache' would look up $wgRedisServers['cached']
  *					Default: Uses the first index of $wgRedisServers.
  * @param	array	[Optional] Additional options, will merge and overwrite default options.
  *					- connectTimeout : The timeout for new connections, in seconds.
  *                      Optional, default is 1 second.
  *					- persistent     : Set this to true to allow connections to persist across
  *                      multiple web requests. False by default.
  *					- password       : The authentication password, will be sent to Redis in clear text.
  *                      Optional, if it is unspecified, no AUTH command will be sent.
  *					- serializer     : Set to "php", "igbinary", or "none". Default is "php".
  * @param	boolean	[Optional] Force a new connection, useful when forking processes.
  * @return	mixed	Object RedisConnRef or false on failure.
  */
 public static function getClient($group = null, $options = [], $newConnection = false)
 {
     global $wgRedisServers;
     if (!extension_loaded('redis')) {
         throw new MWException(__METHOD__ . " - The PHP Redis extension is not available.  Please enable it on the server to use RedisCache.");
     }
     if (empty($wgRedisServers) || !is_array($wgRedisServers)) {
         MWDebug::log(__METHOD__ . " - \$wgRedisServers must be configured for RedisCache to function.");
         return false;
     }
     if (empty($group)) {
         $group = 0;
         $server = current($wgRedisServers);
     } else {
         $server = $wgRedisServers[$group];
     }
     if ($newConnection === false && array_key_exists($group, self::$servers)) {
         return self::$servers[$group];
     }
     if (empty($server) || !is_array($server)) {
         throw new MWException(__METHOD__ . " - An invalid server group key was passed.");
     }
     $pool = \RedisConnectionPool::singleton(array_merge($server['options'], $options));
     $redis = $pool->getConnection($server['host'] . ":" . $server['port']);
     //Concatenate these together for MediaWiki weirdness so it can split them later.
     if ($redis instanceof RedisConnRef) {
         //Set up any extra options.  RedisConnectionPool does not handle the prefix automatically.
         if (!empty($server['options']['prefix'])) {
             $redis->setOption(Redis::OPT_PREFIX, $server['options']['prefix']);
         }
         try {
             $pong = $redis->ping();
             if ($pong === '+PONG') {
                 self::$servers[$group] = $redis;
             } else {
                 $redis = false;
             }
         } catch (RedisException $e) {
             //People using HAProxy will find it will lie about a Redis cluster being healthy when the master is down, but the slaves are up.  Doing a PING will cause an immediate disconnect.
             self::$lastError = $e->getMessage();
             $redis = false;
         }
     }
     return $redis;
 }
开发者ID:HydraWiki,项目名称:RedisCache,代码行数:63,代码来源:RedisCache.php


示例3: testAppendDebugInfoToApiResultXmlFormat

 /**
  * @covers MWDebug::appendDebugInfoToApiResult
  */
 public function testAppendDebugInfoToApiResultXmlFormat()
 {
     $request = $this->newApiRequest(['action' => 'help', 'format' => 'xml'], '/api.php?action=help&format=xml');
     $context = new RequestContext();
     $context->setRequest($request);
     $apiMain = new ApiMain($context);
     $result = new ApiResult($apiMain);
     MWDebug::appendDebugInfoToApiResult($context, $result);
     $this->assertInstanceOf('ApiResult', $result);
     $data = $result->getResultData();
     $expectedKeys = ['mwVersion', 'phpEngine', 'phpVersion', 'gitRevision', 'gitBranch', 'gitViewUrl', 'time', 'log', 'debugLog', 'queries', 'request', 'memory', 'memoryPeak', 'includes', '_element'];
     foreach ($expectedKeys as $expectedKey) {
         $this->assertArrayHasKey($expectedKey, $data['debuginfo'], "debuginfo has {$expectedKey}");
     }
     $xml = ApiFormatXml::recXmlPrint('help', $data);
     // exception not thrown
     $this->assertInternalType('string', $xml);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:21,代码来源:MWDebugTest.php


示例4: hOutputPageParserOutput

 /**
  * Main Hook
  */
 public static function hOutputPageParserOutput(&$op, $parserOutput)
 {
     $action = $op->parserOptions()->getUser()->getRequest()->getVal("action");
     if ($action == 'edit' || $action == 'submit' || $action == 'history') {
         return true;
     }
     global $wgTitle, $wgOut;
     $ns = $wgTitle->getNsText();
     $name = $wgTitle->getPrefixedDBKey();
     $text = $parserOutput->getText();
     $categories = $wgTitle->getParentCategories();
     $categories = array_keys($categories);
     var_dump($categories);
     $categories = array_map(function ($cat) {
         return Title::newFromText($cat, NS_CATEGORY)->getText();
     }, $categories);
     var_dump($categories);
     //MWDebug::warning( "ns=" . $ns ) ;
     //MWDebug::warning( "name=" . $name ) ;
     $nsheader = "hf-nsheader-{$ns}";
     $nsfooter = "hf-nsfooter-{$ns}";
     $header = "hf-header-{$name}";
     $footer = "hf-footer-{$name}";
     /**
      * headers/footers are wrapped around page content.
      * header:	page + namespace + categories in reverse alphabetical order
      * footer:	categories in alphabetical order + namespace + page
      */
     $text = '<div class="hf-header">' . self::conditionalInclude($text, '__NOHEADER__', $header) . '</div>' . $text;
     $text = '<div class="hf-nsheader">' . self::conditionalInclude($text, '__NONSHEADER__', $nsheader) . '</div>' . $text;
     foreach ($categories as &$category) {
         MWDebug::warning("cat=" . $category);
         $catheader = "hf-catheader-{$category}";
         $text = '<div class="hf-catheader">' . self::conditionalInclude($text, '__NOCATHEADER__', $catheader) . '</div>' . $text;
         $catfooter = "hf-catfooter-{$category}";
         $text .= '<div class="hf-catfooter">' . self::conditionalInclude($text, '__NOCATFOOTER__', $catfooter) . '</div>';
     }
     ////
     $text .= '<div class="hf-footer">' . self::conditionalInclude($text, '__NOFOOTER__', $footer) . '</div>';
     $text .= '<div class="hf-nsfooter">' . self::conditionalInclude($text, '__NONSFOOTER__', $nsfooter) . '</div>';
     $parserOutput->setText($text);
     return true;
 }
开发者ID:sm8ps,项目名称:HeaderFooter,代码行数:46,代码来源:HeaderFooter.class.debug.php


示例5: execute

 public function execute($parameters)
 {
     $out = $this->getOutput();
     $skin = $this->getSkin();
     $this->setHeaders();
     $out->setArticleBodyOnly(true);
     // Default modules copied from OutputPage::addDefaultModules
     $out->addModules(array('mediawiki.user', 'mediawiki.page.startup', 'mediawiki.page.ready'));
     $out->addModules(array('ext.cx.header', 'ext.cx.stats'));
     // Load legacy modules if any, for the skin.
     // Some wikis have Common.js scripts that depend on this module.
     $defaultSkinModules = $skin->getDefaultModules();
     $out->addModules($defaultSkinModules['legacy']);
     Hooks::run('BeforePageDisplay', array(&$out, &$skin));
     $out->addHTML($out->headElement($skin));
     $out->addHTML(Html::element('noscript', array(), $this->msg('cx-javascript')->text()));
     $out->addHtml(MWDebug::getDebugHTML($this->getContext()));
     $toolbarList = Html::rawElement('ul', null, $skin->getPersonalToolsList());
     $out->addHTML(Html::rawElement('div', array('id' => 'p-personal'), $toolbarList));
     $out->addHTML($skin->bottomScripts());
     $out->addHTML('</body></html>');
 }
开发者ID:Wikia,项目名称:mediawiki-extensions-ContentTranslation,代码行数:22,代码来源:SpecialContentTranslationStats.php


示例6: 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;
    MWDebug::warning($msg, $callerOffset + 2);
    $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");
    }
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:38,代码来源:GlobalFunctions.php


示例7: generateDebugHTML

 /**
  * Generate debug data HTML for displaying at the bottom of the main content
  * area.
  * @return String HTML containing debug data, if enabled (otherwise empty).
  */
 protected function generateDebugHTML()
 {
     global $wgShowDebug;
     $html = MWDebug::getDebugHTML($this->getContext());
     if ($wgShowDebug) {
         $listInternals = $this->formatDebugHTML($this->getOutput()->mDebugtext);
         $html .= "\n<hr />\n<strong>Debug data:</strong><ul id=\"mw-debug-html\">" . $listInternals . "</ul>\n";
     }
     return $html;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:Skin.php


示例8: printTrail

 /**
  * Output the basic end-page trail including bottomscripts, reporttime, and
  * debug stuff. This should be called right before outputting the closing
  * body and html tags.
  */
 function printTrail()
 {
     echo MWDebug::getDebugHTML($this->getSkin()->getContext());
     $this->html('bottomscripts');
     /* JS call to runBodyOnloadHook */
     $this->html('reporttime');
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:BaseTemplate.php


示例9: output

 /**
  * Finally, all the text has been munged and accumulated into
  * the object, let's actually output it:
  */
 public function output()
 {
     global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP, $wgUseAjax, $wgResponsiveImages;
     if ($this->mDoNothing) {
         return;
     }
     wfProfileIn(__METHOD__);
     $response = $this->getRequest()->response();
     if ($this->mRedirect != '') {
         # Standards require redirect URLs to be absolute
         $this->mRedirect = wfExpandUrl($this->mRedirect, PROTO_CURRENT);
         $redirect = $this->mRedirect;
         $code = $this->mRedirectCode;
         if (wfRunHooks("BeforePageRedirect", array($this, &$redirect, &$code))) {
             if ($code == '301' || $code == '303') {
                 if (!$wgDebugRedirects) {
                     $message = HttpStatus::getMessage($code);
                     $response->header("HTTP/1.1 {$code} {$message}");
                 }
                 $this->mLastModified = wfTimestamp(TS_RFC2822);
             }
             if ($wgVaryOnXFP) {
                 $this->addVaryHeader('X-Forwarded-Proto');
             }
             $this->sendCacheControl();
             $response->header("Content-Type: text/html; charset=utf-8");
             if ($wgDebugRedirects) {
                 $url = htmlspecialchars($redirect);
                 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
                 print "<p>Location: <a href=\"{$url}\">{$url}</a></p>\n";
                 print "</body>\n</html>\n";
             } else {
                 $response->header('Location: ' . $redirect);
             }
         }
         wfProfileOut(__METHOD__);
         return;
     } elseif ($this->mStatusCode) {
         $message = HttpStatus::getMessage($this->mStatusCode);
         if ($message) {
             $response->header('HTTP/1.1 ' . $this->mStatusCode . ' ' . $message);
         }
     }
     # Buffer output; final headers may depend on later processing
     ob_start();
     $response->header("Content-type: {$wgMimeType}; charset=UTF-8");
     $response->header('Content-language: ' . $wgLanguageCode);
     // Prevent framing, if requested
     $frameOptions = $this->getFrameOptions();
     if ($frameOptions) {
         $response->header("X-Frame-Options: {$frameOptions}");
     }
     if ($this->mArticleBodyOnly) {
         echo $this->mBodytext;
     } else {
         $sk = $this->getSkin();
         // add skin specific modules
         $modules = $sk->getDefaultModules();
         // enforce various default modules for all skins
         $coreModules = array('mediawiki.page.startup', 'mediawiki.user');
         // Support for high-density display images if enabled
         if ($wgResponsiveImages) {
             $coreModules[] = 'mediawiki.hidpi';
         }
         $this->addModules($coreModules);
         foreach ($modules as $group) {
             $this->addModules($group);
         }
         MWDebug::addModules($this);
         if ($wgUseAjax) {
             // FIXME: deprecate? - not clear why this is useful
             wfRunHooks('AjaxAddScript', array(&$this));
         }
         // Hook that allows last minute changes to the output page, e.g.
         // adding of CSS or Javascript by extensions.
         wfRunHooks('BeforePageDisplay', array(&$this, &$sk));
         wfProfileIn('Output-skin');
         $sk->outputPage();
         wfProfileOut('Output-skin');
     }
     // This hook allows last minute changes to final overall output by modifying output buffer
     wfRunHooks('AfterFinalPageOutput', array($this));
     $this->sendCacheControl();
     ob_end_flush();
     wfProfileOut(__METHOD__);
 }
开发者ID:spring,项目名称:spring-website,代码行数:90,代码来源:OutputPage.php


示例10: executeAndProfileQuery

 /**
  * Execute and profile the query. This is a wrapper for capturing timing information
  * while executing a query.
  *
  * @param string $sql the query
  * @param string $fname the function name
  * @param bool $isMaster is this against the master
  *
  * @return ResultWrapper|resource|bool see doQuery
  */
 protected function executeAndProfileQuery($sql, $fname, $isMaster)
 {
     $queryId = MWDebug::query($sql, $fname, $isMaster);
     $start = microtime(true);
     // Wikia change: DatabaseMysql returns a resource instead of ResultWrapper instance
     /* @var $ret resource|bool */
     $ret = $this->doQuery($sql);
     $this->logSql($sql, $ret, $fname, microtime(true) - $start, $isMaster);
     MWDebug::queryTime($queryId);
     return $ret;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:21,代码来源:Database.php


示例11: GlobalVarConfig

}
$wgSessionsInObjectCache = true;
if ($wgPHPSessionHandling !== 'enable' && $wgPHPSessionHandling !== 'warn' && $wgPHPSessionHandling !== 'disable') {
    $wgPHPSessionHandling = 'warn';
}
if (defined('MW_NO_SESSION')) {
    // If the entry point wants no session, force 'disable' here unless they
    // specifically set it to the (undocumented) 'warn'.
    $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable';
}
Profiler::instance()->scopedProfileOut($ps_default);
// Disable MWDebug for command line mode, this prevents MWDebug from eating up
// all the memory from logging SQL queries on maintenance scripts
global $wgCommandLineMode;
if ($wgDebugToolbar && !$wgCommandLineMode) {
    MWDebug::init();
}
if (!class_exists('AutoLoader')) {
    require_once "{$IP}/includes/AutoLoader.php";
}
// Reset the global service locator, so any services that have already been created will be
// re-created while taking into account any custom settings and extensions.
MediaWikiServices::resetGlobalInstance(new GlobalVarConfig(), 'quick');
if ($wgSharedDB && $wgSharedTables) {
    // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
    MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(array_fill_keys($wgSharedTables, ['dbname' => $wgSharedDB, 'schema' => $wgSharedSchema, 'prefix' => $wgSharedPrefix]));
}
// Define a constant that indicates that the bootstrapping of the service locator
// is complete.
define('MW_SERVICE_BOOTSTRAP_COMPLETE', 1);
// Install a header callback to prevent caching of responses with cookies (T127993)
开发者ID:paladox,项目名称:mediawiki,代码行数:31,代码来源:Setup.php


示例12: query

 /**
  * Run an SQL query and return the result. Normally throws a DBQueryError
  * on failure. If errors are ignored, returns false instead.
  *
  * In new code, the query wrappers select(), insert(), update(), delete(),
  * etc. should be used where possible, since they give much better DBMS
  * independence and automatically quote or validate user input in a variety
  * of contexts. This function is generally only useful for queries which are
  * explicitly DBMS-dependent and are unsupported by the query wrappers, such
  * as CREATE TABLE.
  *
  * However, the query wrappers themselves should call this function.
  *
  * @param string $sql SQL query
  * @param string $fname Name of the calling function, for profiling/SHOW PROCESSLIST
  *     comment (you can use __METHOD__ or add some extra info)
  * @param bool $tempIgnore Whether to avoid throwing an exception on errors...
  *     maybe best to catch the exception instead?
  * @throws MWException
  * @return bool|ResultWrapper True for a successful write query, ResultWrapper object
  *     for a successful read query, or false on failure if $tempIgnore set
  */
 public function query($sql, $fname = __METHOD__, $tempIgnore = false)
 {
     global $wgUser;
     $this->mLastQuery = $sql;
     $isWriteQuery = $this->isWriteQuery($sql);
     if ($isWriteQuery) {
         $reason = $this->getReadOnlyReason();
         if ($reason !== false) {
             throw new DBReadOnlyError($this, "Database is read-only: {$reason}");
         }
         # Set a flag indicating that writes have been done
         $this->mDoneWrites = microtime(true);
     }
     # Add a comment for easy SHOW PROCESSLIST interpretation
     if (is_object($wgUser) && $wgUser->isItemLoaded('name')) {
         $userName = $wgUser->getName();
         if (mb_strlen($userName) > 15) {
             $userName = mb_substr($userName, 0, 15) . '...';
         }
         $userName = str_replace('/', '', $userName);
     } else {
         $userName = '';
     }
     // Add trace comment to the begin of the sql string, right after the operator.
     // Or, for one-word queries (like "BEGIN" or COMMIT") add it to the end (bug 42598)
     $commentedSql = preg_replace('/\\s|$/', " /* {$fname} {$userName} */ ", $sql, 1);
     if (!$this->mTrxLevel && $this->getFlag(DBO_TRX) && $this->isTransactableQuery($sql)) {
         $this->begin(__METHOD__ . " ({$fname})");
         $this->mTrxAutomatic = true;
     }
     # Keep track of whether the transaction has write queries pending
     if ($this->mTrxLevel && !$this->mTrxDoneWrites && $isWriteQuery) {
         $this->mTrxDoneWrites = true;
         $this->getTransactionProfiler()->transactionWritingIn($this->mServer, $this->mDBname, $this->mTrxShortId);
     }
     $isMaster = !is_null($this->getLBInfo('master'));
     # generalizeSQL will probably cut down the query to reasonable
     # logging size most of the time. The substr is really just a sanity check.
     if ($isMaster) {
         $queryProf = 'query-m: ' . substr(DatabaseBase::generalizeSQL($sql), 0, 255);
         $totalProf = 'DatabaseBase::query-master';
     } else {
         $queryProf = 'query: ' . substr(DatabaseBase::generalizeSQL($sql), 0, 255);
         $totalProf = 'DatabaseBase::query';
     }
     # Include query transaction state
     $queryProf .= $this->mTrxShortId ? " [TRX#{$this->mTrxShortId}]" : "";
     $profiler = Profiler::instance();
     if (!$profiler instanceof ProfilerStub) {
         $totalProfSection = $profiler->scopedProfileIn($totalProf);
         $queryProfSection = $profiler->scopedProfileIn($queryProf);
     }
     if ($this->debug()) {
         wfDebugLog('queries', sprintf("%s: %s", $this->mDBname, $sql));
     }
     $queryId = MWDebug::query($sql, $fname, $isMaster);
     # Avoid fatals if close() was called
     $this->assertOpen();
     # Do the query and handle errors
     $startTime = microtime(true);
     $ret = $this->doQuery($commentedSql);
     $queryRuntime = microtime(true) - $startTime;
     # Log the query time and feed it into the DB trx profiler
     $this->getTransactionProfiler()->recordQueryCompletion($queryProf, $startTime, $isWriteQuery, $this->affectedRows());
     MWDebug::queryTime($queryId);
     # Try reconnecting if the connection was lost
     if (false === $ret && $this->wasErrorReissuable()) {
         # Transaction is gone, like it or not
         $hadTrx = $this->mTrxLevel;
         // possible lost transaction
         $this->mTrxLevel = 0;
         $this->mTrxIdleCallbacks = array();
         // bug 65263
         $this->mTrxPreCommitCallbacks = array();
         // bug 65263
         wfDebug("Connection lost, reconnecting...\n");
         # Stash the last error values since ping() might clear them
         $lastError = $this->lastError();
//.........这里部分代码省略.........
开发者ID:pirater,项目名称:mediawiki,代码行数:101,代码来源:Database.php


示例13: query

	/**
	 * Run an SQL query and return the result. Normally throws a DBQueryError
	 * on failure. If errors are ignored, returns false instead.
	 *
	 * In new code, the query wrappers select(), insert(), update(), delete(),
	 * etc. should be used where possible, since they give much better DBMS
	 * independence and automatically quote or validate user input in a variety
	 * of contexts. This function is generally only useful for queries which are
	 * explicitly DBMS-dependent and are unsupported by the query wrappers, such
	 * as CREATE TABLE.
	 *
	 * However, the query wrappers themselves should call this function.
	 *
	 * @param  $sql        String: SQL query
	 * @param  $fname      String: Name of the calling function, for profiling/SHOW PROCESSLIST
	 *     comment (you can use __METHOD__ or add some extra info)
	 * @param  $tempIgnore Boolean:   Whether to avoid throwing an exception on errors...
	 *     maybe best to catch the exception instead?
	 * @throws MWException
	 * @return boolean|ResultWrapper. true for a successful write query, ResultWrapper object
	 *     for a successful read query, or false on failure if $tempIgnore set
	 */
	public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) {
		global $wgUser, $wgDebugDBTransactions;

		$this->mLastQuery = $sql;
		if ( !$this->mDoneWrites && $this->isWriteQuery( $sql ) ) {
			# Set a flag indicating that writes have been done
			wfDebug( __METHOD__ . ": Writes done: $sql\n" );
			$this->mDoneWrites = true;
		}

		# Add a comment for easy SHOW PROCESSLIST interpretation
		if ( is_object( $wgUser ) && $wgUser->isItemLoaded( 'name' ) ) {
			$userName = $wgUser->getName();
			if ( mb_strlen( $userName ) > 15 ) {
				$userName = mb_substr( $userName, 0, 15 ) . '...';
			}
			$userName = str_replace( '/', '', $userName );
		} else {
			$userName = '';
		}

		// Add trace comment to the begin of the sql string, right after the operator.
		// Or, for one-word queries (like "BEGIN" or COMMIT") add it to the end (bug 42598)
		$commentedSql = preg_replace( '/\s|$/', " /* $fname $userName */ ", $sql, 1 );

		# If DBO_TRX is set, start a transaction
		if ( ( $this->mFlags & DBO_TRX ) && !$this->mTrxLevel &&
			$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 && strpos( $sqlstart, "SET " ) !== 0 ) {
				if ( $wgDebugDBTransactions ) {
					wfDebug( "Implicit transaction start.\n" );
				}
				$this->begin( __METHOD__ . " ($fname)" );
				$this->mTrxAutomatic = true;
			}
		}

		# Keep track of whether the transaction has write queries pending
		if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $this->isWriteQuery( $sql ) ) {
			$this->mTrxDoneWrites = true;
			Profiler::instance()->transactionWritingIn( $this->mServer, $this->mDBname );
		}

		$isMaster = !is_null( $this->getLBInfo( 'master' ) );
		if ( !Profiler::instance()->isStub() ) {
			# generalizeSQL will probably cut down the query to reasonable
			# logging size most of the time. The substr is really just a sanity check.
			if ( $isMaster ) {
				$queryProf = 'query-m: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 );
				$totalProf = 'DatabaseBase::query-master';
			} else {
				$queryProf = 'query: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 );
				$totalProf = 'DatabaseBase::query';
			}
			wfProfileIn( $totalProf );
			wfProfileIn( $queryProf );
		}

		if ( $this->debug() ) {
			static $cnt = 0;

			$cnt++;
			$sqlx = substr( $commentedSql, 0, 500 );
			$sqlx = strtr( $sqlx, "\t\n", '  ' );

			$master = $isMaster ? 'master' : 'slave';
			wfDebug( "Query {$this->mDBname} ($cnt) ($master): $sqlx\n" );
		}

		$queryId = MWDebug::query( $sql, $fname, $isMaster );

		# Do the query and handle errors
		$ret = $this->doQuery( $commentedSql );
//.........这里部分代码省略.........
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:101,代码来源:Database.php


示例14: addDefaultModules

 /**
  * Add the default ResourceLoader modules to this object
  */
 private function addDefaultModules()
 {
     global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
     // Add base resources
     $this->addModules(array('mediawiki.user', 'mediawiki.page.startup', 'mediawiki.page.ready'));
     if ($wgIncludeLegacyJavaScript) {
         $this->addModules('mediawiki.legacy.wikibits');
     }
     if ($wgPreloadJavaScriptMwUtil) {
         $this->addModules('mediawiki.util');
     }
     MWDebug::addModules($this);
     $skin = $this->getSkin();
     // Add various resources if required
     if ($wgUseAjax) {
         # macbre: following files are part of merged JS for following skins - don't load them from here
         $skinName = get_class($skin);
         $skipWikiaSkins = array();
         if (!in_array($skinName, $skipWikiaSkins)) {
             $this->addModules('mediawiki.legacy.ajax');
         }
         wfRunHooks('AjaxAddScript', array(&$this));
         if (!in_array($skinName, $skipWikiaSkins)) {
             if ($wgAjaxWatch && $this->getUser()->isLoggedIn()) {
                 $this->addModules('mediawiki.action.watch.ajax');
             }
         }
         if (!in_array($skinName, $skipWikiaSkins)) {
             if ($wgEnableMWSuggest && !$this->getUser()->getOption('disablesuggest', false)) {
                 $this->addModules('mediawiki.legacy.mwsuggest');
             }
         }
     }
     if ($this->getUser()->getBoolOption('editsectiononrightclick')) {
         $this->addModules('mediawiki.action.view.rightClickEdit');
     }
     # Crazy edit-on-double-click stuff
     if ($this->isArticle() && $this->getUser()->getOption('editondblclick')) {
         $this->addModules('mediawiki.action.view.dblClickEdit');
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:44,代码来源:OutputPage.php


示例15: executeAction

 /**
  * Execute the actual module, without any error handling
  */
 protected function executeAction()
 {
     $params = $this->setupExecuteAction();
     $module = $this->setupModule();
     $this->checkExecutePermissions($module);
     if (!$this->checkMaxLag($module, $params)) {
         return;
     }
     if (!$this->mInternalMode) {
         $this->setupExternalResponse($module, $params);
     }
     // Execute
     $module->profileIn();
     $module->execute();
     wfRunHooks('APIAfterExecute', array(&$module));
     $module->profileOut();
     if (!$this->mInternalMode) {
         //append Debug information
         MWDebug::appendDebugInfoToApiResult($this->getContext(), $this->getResult());
         // Print result data
         $this->printResult(false);
     }
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:26,代码来源:ApiMain.php


示例16: addDefaultModules

 /**
  * Add the default ResourceLoader modules to this object
  */
 private function addDefaultModules()
 {
     global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
     // Add base resources
     $this->addModules(array('mediawiki.user', 'mediawiki.page.startup', 'mediawiki.page.ready'));
     if ($wgIncludeLegacyJavaScript) {
         $this->addModules('mediawiki.legacy.wikibits');
     }
     if ($wgPreloadJavaScriptMwUtil) {
         $this->addModules('mediawiki.util');
     }
     MWDebug::addModules($this);
     // Add various resources if required
     if ($wgUseAjax) {
         $this->addModules('mediawiki.legacy.ajax');
         wfRunHooks('AjaxAddScript', array(&$this));
         if ($wgAjaxWatch && $this->getUser()->isLoggedIn()) {
             $this->addModules('mediawiki.action.watch.ajax');
         }
         if ($wgEnableMWSuggest && !$this->getUser()->getOption('disablesuggest', false)) {
             $this->addModules('mediawiki.legacy.mwsuggest');
         }
     }
     if ($this->getUser()->getBoolOption('editsectiononrightclick')) {
         $this->addModules('mediawiki.action.view.rightClickEdit');
     }
     # Crazy edit-on-double-click stuff
     if ($this->isArticle() && $this->getUser()->getOption('editondblclick')) {
         $this->addModules('mediawiki.action.view.dblClickEdit');
     }
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:34,代码来源:OutputPage.php


示例17: query

 /**
  * Run an SQL query and return the result. Normally throws a DBQueryError
  * on failure. If errors are ignored, returns false instead.
  *
  * In new code, the query wrappers select(), insert(), update(), delete(),
  * etc. should be used where possible, since they give much better DBMS
  * independence and automatically quote or validate user input in a variety
  * of contexts. This function is generally only useful for queries which are
  * explicitly DBMS-dependent and are unsupported by the query wrappers, such
  * as CREATE TABLE.
  *
  * However, the query wrappers themselves should call this function.
  *
  * @param  $sql        String: SQL query
  * @param  $fname      String: Name of the calling function, for profiling/SHOW PROCESSLIST
  *     comment (you can use __METHOD__ or add some extra info)
  * @param  $tempIgnore Boolean:   Whether to avoid throwing an exception on errors...
  *     maybe best to catch the exception instead?
  * @return boolean|ResultWrapper. true for a successful write query, ResultWrapper object
  *     for a successful read query, or false on failure if $tempIgnore set
  * @throws DBQueryError Thrown when the database returns an error of any kind
  */
 public function query($sql, $fname = '', $tempIgnore = false)
 {
     $isMaster = !is_null($this->getLBInfo('master'));
     if (!Profiler::instance()->isStub()) {
         # generalizeSQL will probably cut down the query to reasonable
         # logging size most of the time. The substr is really just a sanity check.
         if ($isMaster) {
             $queryProf = 'query-m: ' . substr(DatabaseBase::generalizeSQL($sql), 0, 255);
             $totalProf = 'DatabaseBase::query-master';
         } else {
             $queryProf = 'query: ' . substr(DatabaseBase::generalizeSQL($sql), 0, 255);
             $totalProf = 'DatabaseBase::query';
         }
         wfProfileIn($totalProf);
         wfProfileIn($queryProf);
     }
     $this->mLastQuery = $sql;
     if (!$this->mDoneWrites && $this->isWriteQuery($sql)) {
         # Set a flag indicating that writes have been done
         wfDebug(__METHOD__ . ": Writes done: {$sql}\n");
         $this->mDoneWrites = true;
     }
     # Add a comment for easy SHOW PROCESSLIST interpretation
     global $wgUser;
     if (is_object($wgUser) && $wgUser->isItemLoaded('name')) {
         $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);
     # 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 && strpos($sqlstart, "SET ") !== 0) {
             $this->begin(__METHOD__ . " ({$fname})");
         }
     }
     if ($this->debug()) {
         static $cnt = 0;
         $cnt++;
         $sqlx = substr($commentedSql, 0, 500);
         $sqlx = strtr($sqlx, "\t\n", '  ');
         $master = $isMaster ? 'master' : 'slave';
         wfDebug("Query {$this->mDBname} ({$cnt}) ({$master}): {$sqlx}\n");
     }
     if (istainted($sql) & TC_MYSQL) {
         throw new MWException('Tainted query found');
     }
     $queryId = MWDebug::query($sql, $fname, $isMaster);
     # Do the query and handle errors
     $ret = $this->doQuery($commentedSql);
     MWDebug::queryTime($queryId);
     # Try reconnecting if the connection was lost
     if (false === $ret && $this->wasErrorReissuable()) {
         # 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);
             if ($elapsed < 300) {
                 # Not a database error to lose a transaction after a minute or two
                 wfLogDBError("Connection lost and reconnected after {$elapsed}s, query: {$sqlx}\n");
             }
             $ret = $this->doQuery($commentedSql);
         } else {
             wfDebug("Failed\n");
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:media-wiki-law,代码行数:101,代码来源:Database.php


示例18: getDebugHTML

 /**
  * Returns the HTML to add to the page for the toolbar
  *
  * @param $context IContextSource
  * @return string
  */
 public static function getDebugHTML(IContextSource $context)
 {
     if (!self::$enabled) {
         return '';
     }
     global $wgVersion, $wgRequestTime;
     MWDebug::log('MWDebug output complete');
     $request = $context->getRequest();
     $debugInfo = array('mwVersion' => $wgVersion, 'phpVersion' => PHP_VERSION, 'time' => microtime(true) - $wgRequestTime, 'log' => self::$log, 'debugLog' => self::$debug, 'queries' => self::$query, 'request' => array('method' => $_SERVER['REQUEST_METHOD'], 'url' => $request->getRequestURL(), 'headers' => $request->getAllHeaders(), 'params' => $request->getValues()), 'memory' => $context->getLanguage()->formatSize(memory_get_usage()), 'memoryPeak' => $context->getLanguage()->formatSize(memory_get_peak_usage()), 'includes' => self::getFilesIncluded($context));
     // Cannot use OutputPage::addJsConfigVars because those are already outputted
     // by the time this method is called.
     $html = Html::inlineScript(ResourceLoader::makeLoaderConditionalScript(ResourceLoader::makeConfigSetScript(array('debugInfo' => $debugInfo))));
     return $html;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:20,代码来源:Debug.php


示例19: appendDebugInfoToApiResult

 /**
  * Append the debug info to given ApiResult
  *
  * @param $context IContextSource
  * @param $result ApiResult
  */
 public static function appendDebugInfoToApiResult(IContextSource $context, ApiResult $result)
 {
     if (!self::$enabled) {
         return;
     }
     // output errors as debug info, when display_errors is on
     // this is necessary for all non html output of the api, because that clears all errors first
     $obContents = ob_get_contents();
     if ($obContents) {
         $obContentArray = explode('<br />', $obContents);
         foreach ($obContentArray as $obContent) {
             if (trim($obContent)) {
                 self::debugMsg(Sanitizer::stripAllTags($obContent));
             }
         }
     }
     MWDebug::log('MWDebug output complete');
     $debugInfo = self::getDebugInfo($context);
     $result->setIndexedTagName($debugInfo, 'debuginfo');
   

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MWException类代码示例发布时间:2022-05-23
下一篇:
PHP MWCryptRand类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap