本文整理汇总了PHP中MWDebug::log方法的典型用法代码示例。如果您正苦于以下问题:PHP MWDebug::log方法的具体用法?PHP MWDebug::log怎么用?PHP MWDebug::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWDebug
的用法示例。
在下文中一共展示了MWDebug::log方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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;
}
示例3: 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');
$result->setIndexedTagName($debugInfo['log'], 'line');
$result->setIndexedTagName($debugInfo['debugLog'], 'msg');
$result->setIndexedTagName($debugInfo['queries'], 'query');
$result->setIndexedTagName($debugInfo['includes'], 'queries');
$result->addValue(null, 'debuginfo', $debugInfo);
}
示例4: getNextArticleToPatrolInner
//.........这里部分代码省略.........
// has the user skipped any articles?
$cookiename = $wgCookiePrefix . "Rcskip";
$skipids = "";
if (isset($_COOKIE[$cookiename])) {
$cookie_ids = array_unique(split(",", $_COOKIE[$cookiename]));
$ids = array();
//safety first
foreach ($cookie_ids as $id) {
$id = intval($id);
if ($id > 0) {
$ids[] = $id;
}
}
if ($ids) {
$skipids = " AND rc_cur_id NOT IN (" . implode(",", $ids) . ") ";
}
}
$sql .= "{$skipids} ORDER BY rc_timestamp " . ($reverse == 1 ? "" : "DESC ") . "LIMIT 1";
$res = $dbr->query($sql, __METHOD__);
$row = $res->fetchObject();
/*$show=true;
if ($show){
var_dump($_GET);
var_dump($_POST);
echo $sql;
var_dump($row);
exit;
}*/
if ($row) {
$result = array();
$t = Title::makeTitle($row->rc_namespace, $row->rc_title);
if ($t->isRedirect()) {
$wp = new WikiPage($t);
$t = $wp->getRedirectTarget();
}
// if title has been deleted set $t to null so we will skip it
if (!$t->exists()) {
MWDebug::log("{$t} does not exist");
$t = null;
}
$result['rc_cur_id'] = $row->rc_cur_id;
if ($rc_user_filter) {
$result['rchi'] = $result['rclo'] = $row->rc_id;
$result['new'] = $dbr->selectField('recentchanges', array('rc_this_oldid'), array('rc_id' => $row->rc_id));
} else {
// always compare to current version
$result['new'] = $dbr->selectField('revision', array('max(rev_id)'), array('rev_page' => $row->rc_cur_id));
$result['rchi'] = $dbr->selectField('recentchanges', array('rc_id'), array('rc_this_oldid' => $result['new']));
$result['rclo'] = $dbr->selectField('recentchanges', array('min(rc_id)'), array('rc_patrolled' => 0, "rc_cur_id" => $row->rc_cur_id));
// do we have a reverted edit caught between these 2?
// if so, only show the reversion, because otherwise you get the reversion trapped in the middle
// and it shows a weird diff page.
$hi = isset($result['rchi']) ? $result['rchi'] : $row->rc_id;
if ($hi) {
$reverted_id = $dbr->selectField('recentchanges', array('min(rc_id)'), array('rc_comment like ' . $dbr->addQuotes($rollbackCommentPrefix . '%'), "rc_id < {$hi}", "rc_id >= {$result['rclo']}", "rc_cur_id" => $row->rc_cur_id));
if ($reverted_id) {
$result['rchi'] = $reverted_id;
$result['new'] = $dbr->selectField('recentchanges', array('rc_this_oldid'), array('rc_id' => $reverted_id));
$row->rc_id = $result['rchi'];
}
//} else {
// $email = new MailAddress("alerts@wikihow.com");
// $subject = "Could not find hi variable " . date("r");
// $body = print_r($_SERVER, true) . "\n\n" . $sql . "\n\n" . print_r($result, true) . "\n\n\$hi: " . $hi;
// UserMailer::send($email, $email, $subject, $body);
}
if (!$result['rclo']) {
$result['rclo'] = $row->rc_id;
}
if (!$result['rchi']) {
$result['rchi'] = $row->rc_id;
}
// is the last patrolled edit a rollback? if so, show the diff starting at that edit
// makes it more clear when someone has reverted vandalism
$result['vandal'] = 0;
$comm = $dbr->selectField('recentchanges', array('rc_comment'), array('rc_id' => $result['rclo']));
if (strpos($comm, $rollbackCommentPrefix) === 0) {
$row2 = $dbr->selectRow('recentchanges', array('rc_id', 'rc_comment'), array("rc_id < {$result['rclo']}", 'rc_cur_id' => $row->rc_cur_id), __METHOD__, array("ORDER BY" => "rc_id desc", "LIMIT" => 1));
if ($row2) {
$result['rclo'] = $row2->rc_id;
}
$result['vandal'] = 1;
}
}
$result['user'] = $dbr->selectField('recentchanges', array('rc_user_text'), array('rc_this_oldid' => $result['new']));
$result['old'] = $dbr->selectField('recentchanges', array('rc_last_oldid'), array('rc_id' => $result['rclo']));
$result['title'] = $t;
$result['rcid'] = $row->rc_id;
if ($result['rchi'] == $result['rclo']) {
$conds = array('rc_id' => $result['rchi']);
} else {
$conds = array('rc_id <= ' . $result['rchi'], 'rc_id >= ' . $result['rclo']);
}
$result['count'] = $dbr->selectField('recentchanges', array('count(*)'), array("rc_id <= " . $result['rchi'], "rc_id >= " . $result['rclo'], "rc_patrolled" => 0, "rc_cur_id" => $row->rc_cur_id));
$result = self::getListofEditors($result);
return $result;
} else {
return null;
}
}
示例5: getNextTip
private function getNextTip($content)
{
$showCoachTip = $this->showCoachTip(&$content);
$coachTip = null;
if ($showCoachTip) {
$coachTip = $this->getCoachTip(&$content);
MWDebug::log("this will be a coach tip");
}
if (!$coachTip) {
$this->getDBTip(&$content);
}
}
示例6: 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;
}
示例7: fileFromRow
private static function fileFromRow($row)
{
MWDebug::log("will look for file: " . $row->uci_image_name);
return wfFindFile("User-Completed-Image-" . $row->uci_image_name);
}
示例8: getAnonImageFileName
function getAnonImageFileName($id = null)
{
global $IP;
$images = glob($IP . Avatar::ANON_AVATAR_DIR . '/80x80*');
if ($id === null) {
$i = array_rand($images);
} else {
$i = abs($id) % (count($images) - 1);
MWDebug::log("id: {$id}, i: {$i}");
}
return basename($images[$i]);
}