本文整理汇总了PHP中wfWarn函数的典型用法代码示例。如果您正苦于以下问题:PHP wfWarn函数的具体用法?PHP wfWarn怎么用?PHP wfWarn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfWarn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Additional params include:
* - dbDirectory : directory containing the DB and the lock file directory
* [defaults to $wgSQLiteDataDir]
* - dbFilePath : use this to force the path of the DB file
* - trxMode : one of (deferred, immediate, exclusive)
* @param array $p
*/
function __construct(array $p)
{
global $wgSharedDB, $wgSQLiteDataDir;
$this->dbDir = isset($p['dbDirectory']) ? $p['dbDirectory'] : $wgSQLiteDataDir;
if (isset($p['dbFilePath'])) {
parent::__construct($p);
// Standalone .sqlite file mode.
// Super doesn't open when $user is false, but we can work with $dbName,
// which is derived from the file path in this case.
$this->openFile($p['dbFilePath']);
} else {
$this->mDBname = $p['dbname'];
// Stock wiki mode using standard file names per DB.
parent::__construct($p);
// Super doesn't open when $user is false, but we can work with $dbName
if ($p['dbname'] && !$this->isOpen()) {
if ($this->open($p['host'], $p['user'], $p['password'], $p['dbname'])) {
if ($wgSharedDB) {
$this->attachDatabase($wgSharedDB);
}
}
}
}
$this->trxMode = isset($p['trxMode']) ? strtoupper($p['trxMode']) : null;
if ($this->trxMode && !in_array($this->trxMode, array('DEFERRED', 'IMMEDIATE', 'EXCLUSIVE'))) {
$this->trxMode = null;
wfWarn("Invalid SQLite transaction mode provided.");
}
$this->lockMgr = new FSLockManager(array('lockDirectory' => "{$this->dbDir}/locks"));
}
示例2: __construct
/**
* Additional params include:
* - dbDirectory : directory containing the DB and the lock file directory
* [defaults to $wgSQLiteDataDir]
* - dbFilePath : use this to force the path of the DB file
* - trxMode : one of (deferred, immediate, exclusive)
* @param array $p
*/
function __construct(array $p)
{
global $wgSharedDB, $wgSQLiteDataDir;
$this->dbDir = isset($p['dbDirectory']) ? $p['dbDirectory'] : $wgSQLiteDataDir;
if (isset($p['dbFilePath'])) {
$this->mFlags = isset($p['flags']) ? $p['flags'] : 0;
// Standalone .sqlite file mode
$this->openFile($p['dbFilePath']);
// @FIXME: clean up base constructor so this can call super instead
$this->mTrxAtomicLevels = new SplStack();
} else {
$this->mDBname = $p['dbname'];
// Stock wiki mode using standard file names per DB
parent::__construct($p);
// parent doesn't open when $user is false, but we can work with $dbName
if ($p['dbname'] && !$this->isOpen()) {
if ($this->open($p['host'], $p['user'], $p['password'], $p['dbname'])) {
if ($wgSharedDB) {
$this->attachDatabase($wgSharedDB);
}
}
}
}
$this->trxMode = isset($p['trxMode']) ? strtoupper($p['trxMode']) : null;
if ($this->trxMode && !in_array($this->trxMode, array('DEFERRED', 'IMMEDIATE', 'EXCLUSIVE'))) {
$this->trxMode = null;
wfWarn("Invalid SQLite transaction mode provided.");
}
$this->lockMgr = new FSLockManager(array('lockDirectory' => "{$this->dbDir}/locks"));
}
示例3: onAfterInsert
public function onAfterInsert($object, array $row, array $metadata)
{
if (!$object instanceof PostRevision) {
wfWarn(__METHOD__ . ': Object is no PostRevision instance');
return;
}
if (!isset($metadata['workflow'])) {
wfWarn(__METHOD__ . ': Missing required metadata: workflow');
return;
}
$workflow = $metadata['workflow'];
if (!$workflow instanceof Workflow) {
throw new InvalidDataException('Workflow metadata is not Workflow instance');
}
if ($workflow->getType() !== 'topic') {
wfWarn(__METHOD__ . ': Expected "topic" workflow but received "' . $workflow->getType() . '"');
return;
}
/** @var $title Title */
$title = $workflow->getArticleTitle();
if (!$title) {
return;
}
$this->onAfterInsertExpectedChange($row['rev_change_type'], $metadata['workflow']);
}
示例4: cleanWrapped
/**
* Use the HTML tidy extension to use the tidy library in-process,
* saving the overhead of spawning a new process.
*
* @param string $text HTML to check
* @param bool $stderr Whether to read result from error status instead of output
* @param int &$retval Exit code (-1 on internal error)
* @return string|null
*/
protected function cleanWrapped($text, $stderr = false, &$retval = null)
{
if (!class_exists('tidy')) {
wfWarn("Unable to load internal tidy class.");
$retval = -1;
return null;
}
$tidy = new \tidy();
$tidy->parseString($text, $this->config['tidyConfigFile'], 'utf8');
if ($stderr) {
$retval = $tidy->getStatus();
return $tidy->errorBuffer;
}
$tidy->cleanRepair();
$retval = $tidy->getStatus();
if ($retval == 2) {
// 2 is magic number for fatal error
// http://www.php.net/manual/en/function.tidy-get-status.php
$cleansource = null;
} else {
$cleansource = tidy_get_output($tidy);
if (!empty($this->config['debugComment']) && $retval > 0) {
$cleansource .= "<!--\nTidy reports:\n" . str_replace('-->', '-->', $tidy->errorBuffer) . "\n-->";
}
}
return $cleansource;
}
示例5: registerServiceFeature
/**
* Registeres a feature for a service object.
* Registers a warning when the service is not registered, but does not give an error.
*
* @since 0.6.6
*
* @param $serviceIdentifier String: internal service identifier
* @param $featureName String
* @param $featureClassName String
*/
public static function registerServiceFeature($serviceIdentifier, $featureName, $featureClassName)
{
if (array_key_exists($serviceIdentifier, self::$registeredServices)) {
$service = self::getServiceInstance($serviceIdentifier);
$service->addFeature($featureName, $featureClassName);
} else {
// If the feature is not registered, register a warning. This is not an error though!
wfWarn("Tried to register feature '{$featureName}' with class '{$featureClassName}' to non-registered service '{$serviceIdentifier}'.");
}
}
示例6: __construct
function __construct()
{
$this->cliMode = true;
$this->connLogger = new \Psr\Log\NullLogger();
$this->queryLogger = new \Psr\Log\NullLogger();
$this->errorLogger = function (Exception $e) {
wfWarn(get_class($e) . ": {$e->getMessage()}");
};
$this->currentDomain = DatabaseDomain::newUnspecified();
}
示例7: __construct
public function __construct($text, $model_id = CONTENT_MODEL_TEXT)
{
parent::__construct($model_id);
if ($text === null || $text === false) {
wfWarn("TextContent constructed with \$text = " . var_export($text, true) . "! " . "This may indicate an error in the caller's scope.");
$text = '';
}
if (!is_string($text)) {
throw new MWException("TextContent expects a string in the constructor.");
}
$this->mText = $text;
}
示例8: __construct
public function __construct($testName, array $opts = [])
{
$this->testName = $testName;
$this->profiler = new ProfilerStub([]);
$this->trxProfiler = new TransactionProfiler();
$this->cliMode = isset($opts['cliMode']) ? $opts['cliMode'] : true;
$this->connLogger = new \Psr\Log\NullLogger();
$this->queryLogger = new \Psr\Log\NullLogger();
$this->errorLogger = function (Exception $e) {
wfWarn(get_class($e) . ": {$e->getMessage()}");
};
$this->currentDomain = DatabaseDomain::newUnspecified();
}
示例9: manipulate
/**
* @see ParameterManipulation::manipulate
*
* @since 0.7
*/
public function manipulate(Parameter &$parameter, array &$parameters)
{
global $egMapsOLLayerGroups, $egMapsOLAvailableLayers;
$layerDefs = array();
$layerNames = array();
foreach ($parameter->getValue() as $layerOrGroup) {
$lcLayerOrGroup = strtolower($layerOrGroup);
// Layer groups. Loop over all items and add them when not present yet.
if (array_key_exists($lcLayerOrGroup, $egMapsOLLayerGroups)) {
foreach ($egMapsOLLayerGroups[$lcLayerOrGroup] as $layerName) {
if (!in_array($layerName, $layerNames)) {
if (is_array($egMapsOLAvailableLayers[$layerName])) {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName][0];
} else {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName];
}
$layerNames[] = $layerName;
}
}
} elseif (array_key_exists($lcLayerOrGroup, $egMapsOLAvailableLayers)) {
if (!in_array($lcLayerOrGroup, $layerNames)) {
if (is_array($egMapsOLAvailableLayers[$lcLayerOrGroup])) {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup][0];
} else {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup];
}
$layerNames[] = $lcLayerOrGroup;
}
} else {
$title = Title::newFromText($layerOrGroup, Maps_NS_LAYER);
if ($title->getNamespace() == Maps_NS_LAYER && $title->exists()) {
$layerPage = new MapsLayerPage($title);
if ($layerPage->hasValidDefinition('openlayers')) {
$layer = $layerPage->getLayer();
if (!in_array($layerOrGroup, $layerNames)) {
$layerDefs[] = $layer->getJavaScriptDefinition();
$layerNames[] = $layerOrGroup;
}
} else {
wfWarn("Invalid layer ({$layerOrGroup}) encountered after validation.");
}
} else {
wfWarn("Invalid layer ({$layerOrGroup}) encountered after validation.");
}
}
}
$parameter->setValue($layerDefs);
MapsMappingServices::getServiceInstance('openlayers')->addLayerDependencies($this->getDependencies($layerNames));
}
示例10: validate
/**
* @param IContextSource $context
* @param AbstractRevision $newRevision
* @param AbstractRevision|null $oldRevision
* @param Title $title
* @return Status
*/
public function validate(IContextSource $context, AbstractRevision $newRevision, AbstractRevision $oldRevision = null, Title $title)
{
$spamObj = BaseBlacklist::getInstance('spam');
if (!$spamObj instanceof \SpamBlacklist) {
wfWarn(__METHOD__ . ': Expected a SpamBlacklist instance but instead received: ' . get_class($spamObj));
return Status::newFatal('something');
}
$links = $this->getLinks($newRevision, $title);
$matches = $spamObj->filter($links, $title);
if ($matches !== false) {
$status = Status::newFatal('spamprotectiontext');
foreach ($matches as $match) {
$status->fatal('spamprotectionmatch', $match);
}
return $status;
}
return Status::newGood();
}
示例11: getOtherProjectsSiteIds
/**
* Get the site ids of other projects to use.
*
* @param array $siteLinkGroups
* @return string[]
*/
public function getOtherProjectsSiteIds(array $siteLinkGroups)
{
$localSite = $this->getLocalSite();
if ($localSite === null) {
wfWarn('Site not found for ' . $this->localSiteId);
return array();
}
$currentGroupId = $localSite->getGroup();
$otherProjectsSiteIds = array();
$this->expandSpecialGroups($siteLinkGroups);
foreach ($siteLinkGroups as $groupId) {
if ($groupId === $currentGroupId) {
continue;
}
$siteToAdd = $this->getSiteForGroup($groupId, $localSite->getLanguageCode());
if ($siteToAdd) {
$otherProjectsSiteIds[] = $siteToAdd->getGlobalId();
}
}
return $otherProjectsSiteIds;
}
示例12: partitionBacklinkJob
/**
* Break down $job into approximately ($bSize/$cSize) leaf jobs and a single partition
* job that covers the remaining backlink range (if needed). Jobs for the first $bSize
* titles are collated ($cSize per job) into leaf jobs to do actual work. All the
* resulting jobs are of the same class as $job. No partition job is returned if the
* range covered by $job was less than $bSize, as the leaf jobs have full coverage.
*
* The leaf jobs have the 'pages' param set to a (<page ID>:(<namespace>,<DB key>),...)
* map so that the run() function knows what pages to act on. The leaf jobs will keep
* the same job title as the parent job (e.g. $job).
*
* The partition jobs have the 'range' parameter set to a map of the format
* (start:<integer>, end:<integer>, batchSize:<integer>, subranges:((<start>,<end>),...)),
* the 'table' parameter set to that of $job, and the 'recursive' parameter set to true.
* This method can be called on the resulting job to repeat the process again.
*
* The job provided ($job) must have the 'recursive' parameter set to true and the 'table'
* parameter must be set to a backlink table. The job title will be used as the title to
* find backlinks for. Any 'range' parameter must follow the same format as mentioned above.
* This should be managed by recursive calls to this method.
*
* The first jobs return are always the leaf jobs. This lets the caller use push() to
* put them directly into the queue and works well if the queue is FIFO. In such a queue,
* the leaf jobs have to get finished first before anything can resolve the next partition
* job, which keeps the queue very small.
*
* $opts includes:
* - params : extra job parameters to include in each job
*
* @param Job $job
* @param int $bSize BacklinkCache partition size; usually $wgUpdateRowsPerJob
* @param int $cSize Max titles per leaf job; Usually 1 or a modest value
* @param array $opts Optional parameter map
* @return Job[] List of Job objects
*/
public static function partitionBacklinkJob(Job $job, $bSize, $cSize, $opts = array())
{
$class = get_class($job);
$title = $job->getTitle();
$params = $job->getParams();
if (isset($params['pages']) || empty($params['recursive'])) {
$ranges = array();
// sanity; this is a leaf node
wfWarn(__METHOD__ . " called on {$job->getType()} leaf job (explosive recursion).");
} elseif (isset($params['range'])) {
// This is a range job to trigger the insertion of partitioned/title jobs...
$ranges = $params['range']['subranges'];
$realBSize = $params['range']['batchSize'];
} else {
// This is a base job to trigger the insertion of partitioned jobs...
$ranges = $title->getBacklinkCache()->partition($params['table'], $bSize);
$realBSize = $bSize;
}
$extraParams = isset($opts['params']) ? $opts['params'] : array();
$jobs = array();
// Combine the first range (of size $bSize) backlinks into leaf jobs
if (isset($ranges[0])) {
list($start, $end) = $ranges[0];
$titles = $title->getBacklinkCache()->getLinks($params['table'], $start, $end);
foreach (array_chunk(iterator_to_array($titles), $cSize) as $titleBatch) {
$pages = array();
foreach ($titleBatch as $tl) {
$pages[$tl->getArticleId()] = array($tl->getNamespace(), $tl->getDBKey());
}
$jobs[] = new $class($title, array('pages' => $pages) + $extraParams);
}
}
// Take all of the remaining ranges and build a partition job from it
if (isset($ranges[1])) {
$jobs[] = new $class($title, array('recursive' => true, 'table' => $params['table'], 'range' => array('start' => $ranges[1][0], 'end' => $ranges[count($ranges) - 1][1], 'batchSize' => $realBSize, 'subranges' => array_slice($ranges, 1))) + $extraParams);
}
return $jobs;
}
示例13: cleanWrapped
/**
* Spawn an external HTML tidy process and get corrected markup back from it.
* Also called in OutputHandler.php for full page validation
*
* @param string $text HTML to check
* @param bool $stderr Whether to read result from STDERR rather than STDOUT
* @param int &$retval Exit code (-1 on internal error)
* @return string|null
*/
protected function cleanWrapped($text, $stderr = false, &$retval = null)
{
$cleansource = '';
$opts = ' -utf8';
if ($stderr) {
$descriptorspec = [0 => ['pipe', 'r'], 1 => ['file', wfGetNull(), 'a'], 2 => ['pipe', 'w']];
} else {
$descriptorspec = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['file', wfGetNull(), 'a']];
}
$readpipe = $stderr ? 2 : 1;
$pipes = [];
$process = proc_open("{$this->config['tidyBin']} -config {$this->config['tidyConfigFile']} " . $this->config['tidyCommandLine'] . $opts, $descriptorspec, $pipes);
// NOTE: At least on linux, the process will be created even if tidy is not installed.
// This means that missing tidy will be treated as a validation failure.
if (is_resource($process)) {
// Theoretically, this style of communication could cause a deadlock
// here. If the stdout buffer fills up, then writes to stdin could
// block. This doesn't appear to happen with tidy, because tidy only
// writes to stdout after it's finished reading from stdin. Search
// for tidyParseStdin and tidySaveStdout in console/tidy.c
fwrite($pipes[0], $text);
fclose($pipes[0]);
while (!feof($pipes[$readpipe])) {
$cleansource .= fgets($pipes[$readpipe], 1024);
}
fclose($pipes[$readpipe]);
$retval = proc_close($process);
} else {
wfWarn("Unable to start external tidy process");
$retval = -1;
}
if (!$stderr && $cleansource == '' && $text != '') {
// Some kind of error happened, so we couldn't get the corrected text.
// Just give up; we'll use the source text and append a warning.
$cleansource = null;
}
return $cleansource;
}
示例14: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
if (!is_callable('renderGraphviz')) {
wfWarn('The SRF Graph printer needs the GraphViz extension to be installed.');
return '';
}
global $wgGraphVizSettings;
$this->isHTML = true;
$graphInput = "digraph {$this->m_graphName} {";
if ($this->m_graphSize != '') {
$graphInput .= "size=\"{$this->m_graphSize}\";";
}
if ($this->m_nodeShape) {
$graphInput .= "node [shape={$this->m_nodeShape}];";
}
$graphInput .= "rankdir={$this->m_rankdir};";
while ($row = $res->getNext()) {
$graphInput .= $this->getGVForItem($row, $outputmode);
}
$graphInput .= "}";
// Calls renderGraphViz function from MediaWiki GraphViz extension
$result = renderGraphviz($graphInput);
if ($this->m_graphLegend && $this->m_graphColor) {
$arrayCount = 0;
$arraySize = count($this->m_graphColors);
$result .= "<P>";
foreach ($this->m_labelArray as $m_label) {
if ($arrayCount >= $arraySize) {
$arrayCount = 0;
}
$color = $this->m_graphColors[$arrayCount];
$result .= "<font color={$color}>{$color}: {$m_label} </font><br />";
$arrayCount += 1;
}
$result .= "</P>";
}
return $result;
}
示例15: doSchemaUpdate
/**
* @param DatabaseUpdater $updater
*/
public function doSchemaUpdate(DatabaseUpdater $updater)
{
$db = $updater->getDB();
$type = $db->getType();
if ($type !== 'mysql' && $type !== 'sqlite') {
wfWarn("Database type '{$type}' is not supported by the Wikibase repository.");
return;
}
$this->addChangesTable($updater, $type);
// Update from 0.1.
if (!$db->tableExists('wb_terms')) {
$updater->dropTable('wb_items_per_site');
$updater->dropTable('wb_items');
$updater->dropTable('wb_aliases');
$updater->dropTable('wb_texts_per_lang');
$updater->addExtensionTable('wb_terms', $this->getUpdateScriptPath('Wikibase', $db->getType()));
$this->store->rebuild();
}
$this->updateEntityPerPageTable($updater, $db);
$this->updateTermsTable($updater, $db);
$this->updateItemsPerSiteTable($updater, $db);
$this->updateChangesTable($updater, $db);
$this->registerPropertyInfoTableUpdates($updater);
}