本文整理汇总了PHP中wfDebug函数的典型用法代码示例。如果您正苦于以下问题:PHP wfDebug函数的具体用法?PHP wfDebug怎么用?PHP wfDebug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfDebug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupMicroID
function setupMicroID()
{
global $wgOut, $wgRequest, $wgHooks;
$wgHooks['UserToggles'][] = 'MicroIDUserToggle';
$action = $wgRequest->getText('action', 'view');
if ($action == 'view') {
$title = $wgRequest->getText('title');
if (!isset($title) || strlen($title) == 0) {
# If there's no title, and Cache404 is in use, check using its stuff
if (defined('CACHE404_VERSION')) {
if ($_SERVER['REDIRECT_STATUS'] == 404) {
$url = getRedirectUrl($_SERVER);
if (isset($url)) {
$title = cacheUrlToTitle($url);
}
}
} else {
$title = wfMsg('mainpage');
}
}
$nt = Title::newFromText($title);
// If the page being viewed is a user page...
if ($nt && $nt->getNamespace() == NS_USER && strpos($nt->getText(), '/') === false) {
// If the user qualifies...
wfDebug("MicroID: on User page " . $nt->getText() . "\n");
$user = User::newFromName($nt->getText());
if ($user && $user->getID() != 0 && $user->getEmail() && $user->isEmailConfirmed() && $user->getOption('microid')) {
wfDebug("MicroID: on User page " . $nt->getText() . "\n");
$wgOut->addMeta('microid', MakeMicroID($user->getEmail(), $nt->getFullURL()));
}
}
}
}
示例2: debug
function debug($msg)
{
wfDebug("{$msg}\n");
if ($this->debugLog) {
$this->logToFile($msg, $this->debugLog);
}
}
示例3: __construct
/**
* Constructor
* @param $titleObj Title object that the diff is associated with
* @param $old Integer old ID we want to show and diff with.
* @param $new String either 'prev' or 'next'.
* @param $rcid Integer ??? FIXME (default 0)
* @param $refreshCache boolean If set, refreshes the diff cache
* @param $unhide boolean If set, allow viewing deleted revs
*/
function __construct($titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false, $unhide = false)
{
if ($titleObj) {
$this->mTitle = $titleObj;
} else {
global $wgTitle;
$this->mTitle = $wgTitle;
// @TODO: get rid of this
}
wfDebug("DifferenceEngine old '{$old}' new '{$new}' rcid '{$rcid}'\n");
if ('prev' === $new) {
# Show diff between revision $old and the previous one.
# Get previous one from DB.
$this->mNewid = intval($old);
$this->mOldid = $this->mTitle->getPreviousRevisionID($this->mNewid);
} elseif ('next' === $new) {
# Show diff between revision $old and the next one.
# Get next one from DB.
$this->mOldid = intval($old);
$this->mNewid = $this->mTitle->getNextRevisionID($this->mOldid);
if (false === $this->mNewid) {
# if no result, NewId points to the newest old revision. The only newer
# revision is cur, which is "0".
$this->mNewid = 0;
}
} else {
$this->mOldid = intval($old);
$this->mNewid = intval($new);
wfRunHooks('NewDifferenceEngine', array(&$titleObj, &$this->mOldid, &$this->mNewid, $old, $new));
}
$this->mRcidMarkPatrolled = intval($rcid);
# force it to be an integer
$this->mRefreshCache = $refreshCache;
$this->unhide = $unhide;
}
示例4: autoload
/**
* autoload - take a class name and attempt to load it
*
* @param string $className Name of class we're looking for.
* @return bool Returning false is important on failure as
* it allows Zend to try and look in other registered autoloaders
* as well.
*/
static function autoload($className)
{
global $wgAutoloadClasses, $wgAutoloadLocalClasses;
if (isset($wgAutoloadLocalClasses[$className])) {
$filename = $wgAutoloadLocalClasses[$className];
} elseif (isset($wgAutoloadClasses[$className])) {
$filename = $wgAutoloadClasses[$className];
} else {
# Try a different capitalisation
# The case can sometimes be wrong when unserializing PHP 4 objects
$filename = false;
$lowerClass = strtolower($className);
foreach ($wgAutoloadLocalClasses as $class2 => $file2) {
if (strtolower($class2) == $lowerClass) {
$filename = $file2;
}
}
if (!$filename) {
if (function_exists('wfDebug')) {
wfDebug("Class {$className} not found; skipped loading");
}
# Give up
return false;
}
}
# Make an absolute path, this improves performance by avoiding some stat calls
if (substr($filename, 0, 1) != '/' && substr($filename, 1, 1) != ':') {
global $IP;
$filename = "{$IP}/{$filename}";
}
require $filename;
return true;
}
示例5: profileOut
function profileOut($functionname)
{
$memory = memory_get_usage();
$time = $this->getTime();
global $wgDebugProfiling, $wgDebugFunctionEntry;
if ($wgDebugFunctionEntry && function_exists('wfDebug')) {
wfDebug(str_repeat(' ', count($this->mWorkStack) - 1) . 'Exiting ' . $functionname . "\n");
}
$bit = array_pop($this->mWorkStack);
if (!$bit) {
wfDebug("Profiling error, !\$bit: {$functionname}\n");
} else {
//if ($wgDebugProfiling) {
if ($functionname == 'close') {
$message = "Profile section ended by close(): {$bit[0]}\n";
wfDebug($message);
$this->mStack[] = array($message, 0, 0, 0);
} elseif ($bit[0] != $functionname) {
$message = "Profiling error: in({$bit[0]}), out({$functionname})\n";
wfDebug($message);
$this->mStack[] = array($message, 0, 0, 0);
}
//}
$bit[] = $time;
$bit[] = $memory;
$this->mStack[] = $bit;
}
}
示例6: disambiguation_templates
/**
* Return a clause with the list of disambiguation templates.
* This function was copied verbatim from specials/SpecialDisambiguations.php
*/
function disambiguation_templates( $dbr ) {
$dMsgText = wfMsgForContent('disambiguationspage');
$linkBatch = new LinkBatch;
# If the text can be treated as a title, use it verbatim.
# Otherwise, pull the titles from the links table
$dp = Title::newFromText($dMsgText);
if( $dp ) {
if($dp->getNamespace() != NS_TEMPLATE) {
# FIXME we assume the disambiguation message is a template but
# the page can potentially be from another namespace :/
wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
}
$linkBatch->addObj( $dp );
} else {
# Get all the templates linked from the Mediawiki:Disambiguationspage
$disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' );
$res = $dbr->select(
array('pagelinks', 'page'),
'pl_title',
array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE,
'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
__METHOD__ );
foreach ( $res as $row ) {
$linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title ));
}
}
return $linkBatch->constructSet( 'tl', $dbr );
}
示例7: jsonTagRender
/**
* Default parser tag renderer
*/
public static function jsonTagRender($input, array $args, Parser $parser, PPFrame $frame)
{
global $wgJsonData;
$wgJsonData = new JsonData($frame->title);
$json = $input;
$goodschema = true;
try {
$schematext = $wgJsonData->getSchemaText();
} catch (JsonDataException $e) {
$schematext = $wgJsonData->readJsonFromPredefined('openschema');
wfDebug(__METHOD__ . ": " . htmlspecialchars($e->getMessage()) . "\n");
$goodschema = false;
}
$schematitletext = $wgJsonData->getSchemaTitleText();
if ($goodschema && !is_null($schematitletext)) {
// Register dependency in templatelinks, using technique (and a
// little code) from http://www.mediawiki.org/wiki/Manual:Tag_extensions
$schematitle = Title::newFromText($schematitletext);
$schemarev = Revision::newFromTitle($schematitle);
$schemaid = $schemarev ? $schemarev->getPage() : 0;
$parser->mOutput->addTemplate($schematitle, $schemaid, $schemarev ? $schemarev->getId() : 0);
}
$data = json_decode($json, true);
$schema = json_decode($schematext, true);
$rootjson = new JsonTreeRef($data);
$rootjson->attachSchema($schema);
$markup = JsonDataMarkup::getMarkup($rootjson, 0);
return $parser->recursiveTagParse($markup, $frame);
}
示例8: renderTagPage
/**
* Hook: ParserBeforeStrip
* @param $parser Parser
* @param $text
* @param $state
* @return bool
*/
public static function renderTagPage($parser, &$text, $state)
{
$title = $parser->getTitle();
if (strpos($text, '<translate>') !== false) {
try {
$parse = TranslatablePage::newFromText($parser->getTitle(), $text)->getParse();
$text = $parse->getTranslationPageText(null);
} catch (TPException $e) {
// Show ugly preview without processed <translate> tags
wfDebug('TPException caught; expected');
}
}
// Set display title
$page = TranslatablePage::isTranslationPage($title);
if (!$page) {
return true;
}
list(, $code) = TranslateUtils::figureMessage($title->getText());
$name = $page->getPageDisplayTitle($code);
if ($name) {
$name = $parser->recursivePreprocess($name);
$parser->getOutput()->setDisplayTitle($name);
}
// Disable edit section links
$parser->getOptions()->setEditSection(false);
return true;
}
示例9: purge
static function purge($urlArr)
{
$caller = self::getPurgeCaller();
wfDebug("Purging backtrace: " . wfGetAllCallers(false) . "\n");
// Filter urls into buckets based on service backend
$buckets = array_reduce($urlArr, function ($carry, $item) use($caller) {
global $wgPurgeVignetteUsingSurrogateKeys;
wfDebug("Purging URL {$item} from {$caller} via Celery\n");
if (isset($wgPurgeVignetteUsingSurrogateKeys) && VignetteRequest::isVignetteUrl($item)) {
$carry['vignette'][] = $item;
} elseif (strstr($item, 'MercuryApi') !== false) {
$carry['mercury'][] = $item;
$carry['mediawiki'][] = $item;
// TODO: we can remove this when mercury is only using internal cache
} else {
$carry['mediawiki'][] = $item;
}
return $carry;
}, array('mediawiki' => [], 'vignette' => [], 'mercury' => []));
if (empty(CeleryPurge::$buckets)) {
CeleryPurge::$buckets = $buckets;
} else {
CeleryPurge::$buckets = array_merge_recursive(CeleryPurge::$buckets, $buckets);
}
}
示例10: open
/** Open an SQLite database and return a resource handle to it
* NOTE: only $dbName is used, the other parameters are irrelevant for SQLite databases
*/
function open($server, $user, $pass, $dbName)
{
$this->mConn = false;
if ($dbName) {
$file = $this->mDatabaseFile;
try {
if ($this->mFlags & DBO_PERSISTENT) {
$this->mConn = new PDO("sqlite:{$file}", $user, $pass, array(PDO::ATTR_PERSISTENT => true));
} else {
$this->mConn = new PDO("sqlite:{$file}", $user, $pass);
}
} catch (PDOException $e) {
$err = $e->getMessage();
}
if ($this->mConn === false) {
wfDebug("DB connection error: {$err}\n");
if (!$this->mFailFunction) {
throw new DBConnectionError($this, $err);
} else {
return false;
}
}
$this->mOpened = $this->mConn;
# set error codes only, don't raise exceptions
$this->mConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
}
return $this->mConn;
}
示例11: addOlds
/**
* Add the old versions of the image to the batch
*/
function addOlds()
{
$archiveBase = 'archive';
$this->olds = array();
$this->oldCount = 0;
$result = $this->db->select('oldimage', array('oi_archive_name', 'oi_deleted'), array('oi_name' => $this->oldName), __METHOD__);
while ($row = $this->db->fetchObject($result)) {
$oldName = $row->oi_archive_name;
$bits = explode('!', $oldName, 2);
if (count($bits) != 2) {
wfDebug("Invalid old file name: {$oldName} \n");
continue;
}
list($timestamp, $filename) = $bits;
if ($this->oldName != $filename) {
wfDebug("Invalid old file name: {$oldName} \n");
continue;
}
$this->oldCount++;
// Do we want to add those to oldCount?
if ($row->oi_deleted & File::DELETED_FILE) {
continue;
}
$this->olds[] = array("{$archiveBase}/{$this->oldHash}{$oldName}", "{$archiveBase}/{$this->newHash}{$timestamp}!{$this->newName}");
}
$this->db->freeResult($result);
}
示例12: DifferenceEngine
/**
* Constructor
* @param $titleObj Title object that the diff is associated with
* @param $old Integer: old ID we want to show and diff with.
* @param $new String: either 'prev' or 'next'.
* @param $rcid Integer: ??? FIXME (default 0)
* @param $refreshCache boolean If set, refreshes the diff cache
*/
function DifferenceEngine($titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false)
{
$this->mTitle = $titleObj;
wfDebug("DifferenceEngine old '{$old}' new '{$new}' rcid '{$rcid}'\n");
if ('prev' === $new) {
# Show diff between revision $old and the previous one.
# Get previous one from DB.
#
$this->mNewid = intval($old);
$this->mOldid = $this->mTitle->getPreviousRevisionID($this->mNewid);
} elseif ('next' === $new) {
# Show diff between revision $old and the previous one.
# Get previous one from DB.
#
$this->mOldid = intval($old);
$this->mNewid = $this->mTitle->getNextRevisionID($this->mOldid);
if (false === $this->mNewid) {
# if no result, NewId points to the newest old revision. The only newer
# revision is cur, which is "0".
$this->mNewid = 0;
}
} else {
$this->mOldid = intval($old);
$this->mNewid = intval($new);
}
$this->mRcidMarkPatrolled = intval($rcid);
# force it to be an integer
$this->mRefreshCache = $refreshCache;
}
示例13: cleanupDeletedBatch
/**
* Delete files in the deleted directory if they are not referenced in the
* filearchive table. This needs to be done in the repo because it needs to
* interleave database locks with file operations, which is potentially a
* remote operation.
* @return FileRepoStatus
*/
function cleanupDeletedBatch($storageKeys)
{
$root = $this->getZonePath('deleted');
$dbw = $this->getMasterDB();
$status = $this->newGood();
$storageKeys = array_unique($storageKeys);
foreach ($storageKeys as $key) {
$hashPath = $this->getDeletedHashPath($key);
$path = "{$root}/{$hashPath}{$key}";
$dbw->begin();
$inuse = $dbw->selectField('filearchive', '1', array('fa_storage_group' => 'deleted', 'fa_storage_key' => $key), __METHOD__, array('FOR UPDATE'));
if (!$inuse) {
wfDebug(__METHOD__ . ": deleting {$key}\n");
if (!@unlink($path)) {
$status->error('undelete-cleanup-error', $path);
$status->failCount++;
}
} else {
wfDebug(__METHOD__ . ": {$key} still in use\n");
$status->successCount++;
}
$dbw->commit();
}
return $status;
}
示例14: sleep
private function sleep()
{
wfProfileIn(__METHOD__);
wfDebug(sprintf("%s: sleeping for %d ms\n", __CLASS__, $this->mDelay));
usleep($this->mDelay * 1000);
wfProfileOut(__METHOD__);
}
示例15: renderToolTip
function renderToolTip($input, $argv, &$parser)
{
$text = 'see tooltip';
$xoffset = 0;
$yoffset = 0;
foreach ($argv as $key => $value) {
switch ($key) {
case 'text':
$text = $value;
break;
case 'x':
$xoffset = intval($value);
break;
case 'y':
$yoffset = intval($value);
break;
default:
wfDebug(__METHOD__ . ": Requested '{$key} ==> {$value}'\n");
break;
}
}
$output = '';
if ($input != '') {
$tooltipid = uniqid('tooltipid');
$parentid = uniqid('parentid');
$output .= "<span id='{$tooltipid}' class='xstooltip'>" . $parser->unstrip($parser->recursiveTagParse($input), $parser->mStripState) . "</span>";
$output .= "<span id='{$parentid}' class='xstooltip_body' onmouseover=\"xstooltip_show('{$tooltipid}', '{$parentid}', {$xoffset}, {$yoffset});\" onmouseout=\"xstooltip_hide('{$tooltipid}');\">" . $parser->unstrip($parser->recursiveTagParse($text), $parser->mStripState) . "</span>";
}
return $output;
}