本文整理汇总了PHP中wfLogWarning函数的典型用法代码示例。如果您正苦于以下问题:PHP wfLogWarning函数的具体用法?PHP wfLogWarning怎么用?PHP wfLogWarning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfLogWarning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSkinNames
/**
* Fetch the set of available skins.
* @return array associative array of strings
*/
static function getSkinNames()
{
global $wgValidSkinNames;
static $skinsInitialised = false;
if (!$skinsInitialised || !count($wgValidSkinNames)) {
# Get a list of available skins
# Build using the regular expression '^(.*).php$'
# Array keys are all lower case, array value keep the case used by filename
#
wfProfileIn(__METHOD__ . '-init');
global $wgStyleDirectory;
$skinDir = dir($wgStyleDirectory);
if ($skinDir !== false && $skinDir !== null) {
# while code from www.php.net
while (false !== ($file = $skinDir->read())) {
// Skip non-PHP files, hidden files, and '.dep' includes
$matches = array();
if (preg_match('/^([^.]*)\\.php$/', $file, $matches)) {
$aSkin = $matches[1];
// We're still loading core skins via the autodiscovery mechanism... :(
if (!in_array($aSkin, array('CologneBlue', 'Modern', 'MonoBook', 'Vector'))) {
wfLogWarning("A skin using autodiscovery mechanism, {$aSkin}, was found in your skins/ directory. " . "The mechanism will be removed in MediaWiki 1.25 and the skin will no longer be recognized. " . "See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for information how to fix this.");
}
$wgValidSkinNames[strtolower($aSkin)] = $aSkin;
}
}
$skinDir->close();
}
$skinsInitialised = true;
wfProfileOut(__METHOD__ . '-init');
}
return $wgValidSkinNames;
}
示例2: __construct
/**
* @param EntityTitleLookup $titleLookup
* @param EntityContentFactory $entityContentFactory
* @param IContextSource $context
*/
public function __construct(EntityTitleLookup $titleLookup, EntityContentFactory $entityContentFactory, IContextSource $context)
{
if (!$context instanceof MutableContext) {
wfLogWarning('$context is not an instanceof MutableContext.');
$context = new DerivativeContext($context);
}
$this->titleLookup = $titleLookup;
$this->entityContentFactory = $entityContentFactory;
$this->context = $context;
}
示例3: getDiff
/**
* @since 0.1
*
* @param string $cache set to 'cache' to cache the unserialized diff.
*
* @return Diff
*/
public function getDiff($cache = 'no')
{
$info = $this->getInfo($cache);
if (!array_key_exists('diff', $info)) {
// This shouldn't happen, but we should be robust against corrupt, incomplete
// obsolete instances in the database, etc.
wfLogWarning('Cannot get the diff when it has not been set yet.');
return new Diff();
} else {
return $info['diff'];
}
}
示例4: runHook
/**
* @param ItemId $itemId
* @param array $sidebar
*
* @return array
*/
private function runHook(ItemId $itemId, array $sidebar)
{
$newSidebar = $sidebar;
Hooks::run('WikibaseClientOtherProjectsSidebar', array($itemId, &$newSidebar));
if ($newSidebar === $sidebar) {
return $sidebar;
}
if (!is_array($newSidebar) || !$this->isValidSidebar($newSidebar)) {
wfLogWarning('Other projects sidebar data invalid after hook run.');
return $sidebar;
}
return $newSidebar;
}
示例5: getSiteLinkDiff
/**
* @since 0.3
*
* @return Diff
*/
public function getSiteLinkDiff()
{
$diff = $this->getDiff();
if (!$diff instanceof ItemDiff) {
// This shouldn't happen, but we should be robust against corrupt, incomplete
// or obsolete instances in the database, etc.
$cls = $diff === null ? 'null' : get_class($diff);
wfLogWarning('Cannot get sitelink diff from ' . $cls . '. Change #' . $this->getId() . ", type " . $this->getType());
return new Diff();
} else {
return $diff->getSiteLinkDiff();
}
}
示例6: getEntityIdFromOutputPage
/**
* @param OutputPage $out
*
* @return EntityId|null
*/
public function getEntityIdFromOutputPage(OutputPage $out)
{
if (!$this->entityContentFactory->isEntityContentModel($out->getTitle()->getContentModel())) {
return null;
}
$jsConfigVars = $out->getJsConfigVars();
if (array_key_exists('wbEntityId', $jsConfigVars)) {
$idString = $jsConfigVars['wbEntityId'];
try {
return $this->entityIdParser->parse($idString);
} catch (EntityIdParsingException $ex) {
wfLogWarning('Failed to parse EntityId config var: ' . $idString);
}
}
return null;
}
示例7: getValueBuilder
/**
* @param string|null $dataTypeId
* @param string $dataValueType
*
* @return null|ValueSnakRdfBuilder
*/
private function getValueBuilder($dataTypeId, $dataValueType)
{
if ($dataTypeId !== null) {
if (isset($this->valueBuilders["PT:{$dataTypeId}"])) {
return $this->valueBuilders["PT:{$dataTypeId}"];
}
}
if (isset($this->valueBuilders["VT:{$dataValueType}"])) {
return $this->valueBuilders["VT:{$dataValueType}"];
}
if ($dataTypeId !== null) {
wfLogWarning(__METHOD__ . ": No RDF builder defined for data type {$dataTypeId} nor for value type {$dataValueType}.");
} else {
wfLogWarning(__METHOD__ . ": No RDF builder defined for value type {$dataValueType}.");
}
return null;
}
示例8: getEntityRevision
/**
* @since 0.4
* @see EntityRevisionLookup::getEntityRevision
*
* @param EntityId $entityId
* @param int|string $revisionId The desired revision id, or LATEST_FROM_SLAVE or LATEST_FROM_MASTER.
*
* @throws RevisionedUnresolvedRedirectException
* @throws StorageException
* @return EntityRevision|null
*/
public function getEntityRevision(EntityId $entityId, $revisionId = self::LATEST_FROM_SLAVE)
{
wfDebugLog(__CLASS__, __FUNCTION__ . ': Looking up entity ' . $entityId . " (revision {$revisionId}).");
// default changed from false to 0 and then to LATEST_FROM_SLAVE
if ($revisionId === false || $revisionId === 0) {
wfWarn('getEntityRevision() called with $revisionId = false or 0, ' . 'use EntityRevisionLookup::LATEST_FROM_SLAVE or EntityRevisionLookup::LATEST_FROM_MASTER instead.');
$revisionId = self::LATEST_FROM_SLAVE;
}
/** @var EntityRevision $entityRevision */
$entityRevision = null;
if (is_int($revisionId)) {
$row = $this->entityMetaDataAccessor->loadRevisionInformationByRevisionId($entityId, $revisionId);
} else {
$rows = $this->entityMetaDataAccessor->loadRevisionInformation(array($entityId), $revisionId);
$row = $rows[$entityId->getSerialization()];
}
if ($row) {
/** @var EntityRedirect $redirect */
try {
list($entityRevision, $redirect) = $this->loadEntity($row);
} catch (MWContentSerializationException $ex) {
throw new StorageException('Failed to unserialize the content object.', 0, $ex);
}
if ($redirect !== null) {
throw new RevisionedUnresolvedRedirectException($entityId, $redirect->getTargetId(), (int) $row->rev_id, $row->rev_timestamp);
}
if ($entityRevision === null) {
// This only happens when there is a problem with the external store.
wfLogWarning(__METHOD__ . ': Entity not loaded for ' . $entityId);
}
}
if ($entityRevision !== null && !$entityRevision->getEntity()->getId()->equals($entityId)) {
// This can happen when giving a revision ID that doesn't belong to the given entity,
// or some meta data is incorrect.
$actualEntityId = $entityRevision->getEntity()->getId()->getSerialization();
// Get the revision id we actually loaded, if none was passed explicitly
$revisionId = is_int($revisionId) ? $revisionId : $entityRevision->getRevisionId();
throw new BadRevisionException("Revision {$revisionId} belongs to {$actualEntityId} instead of expected {$entityId}");
}
if (is_int($revisionId) && $entityRevision === null) {
// If a revision ID was specified, but that revision doesn't exist:
throw new BadRevisionException("No such revision found for {$entityId}: {$revisionId}");
}
return $entityRevision;
}
示例9: fixSubstructureDiff
/**
* Checks the type of a substructure diff, and replaces it if needed.
* This is needed for backwards compatibility with old versions of
* MapDiffer: As of commit ff65735a125e, MapDiffer may generate atomic diffs for
* substructures even in recursive mode (bug 51363).
*
* @param array &$operations All change ops; This is a reference, so the
* substructure diff can be replaced if need be.
* @param string $key The key of the substructure
*/
protected function fixSubstructureDiff(array &$operations, $key)
{
if (!isset($operations[$key])) {
return;
}
if (!$operations[$key] instanceof Diff) {
$warning = "Invalid substructure diff for key {$key}: " . get_class($operations[$key]);
if (function_exists('wfLogWarning')) {
wfLogWarning($warning);
} else {
trigger_error($warning, E_USER_WARNING);
}
// We could look into the atomic diff, see if it uses arrays as values,
// and construct a new Diff according to these values. But since the
// actual old behavior of MapDiffer didn't cause that to happen, let's
// just use an empty diff, which is what MapDiffer should have returned
// in the actual broken case mentioned in bug 51363.
$operations[$key] = new Diff(array(), true);
}
}
示例10: searchText
/**
* Search revisions with provided term.
*
* @param string $term Term to search
* @return Status
*/
public function searchText($term)
{
// full-text search
$queryString = new QueryString($term);
$queryString->setFields(array('revisions.text'));
$this->query->setQuery($queryString);
// add aggregation to determine exact amount of matching search terms
$terms = $this->getTerms($term);
$this->query->addAggregation($this->termsAggregation($terms));
// @todo: abstract-away this config? (core/cirrus also has this - share it somehow?)
$this->query->setHighlight(array('fields' => array(static::HIGHLIGHT_FIELD => array('type' => 'plain', 'order' => 'score', 'number_of_fragments' => 1, 'fragment_size' => 10000)), 'pre_tags' => array(static::HIGHLIGHT_PRE), 'post_tags' => array(static::HIGHLIGHT_POST)));
// @todo: support insource: queries (and perhaps others)
$searchable = Connection::getFlowIndex($this->indexBaseName);
if ($this->type !== false) {
$searchable = $searchable->getType($this->type);
}
$search = $searchable->createSearch($this->query);
// @todo: PoolCounter config at PoolCounterSettings-eqiad.php
// @todo: do we want this class to extend from ElasticsearchIntermediary and use its success & failure methods (like CirrusSearch/Searcher does)?
// Perform the search
$work = new PoolCounterWorkViaCallback('Flow-Search', "_elasticsearch", array('doWork' => function () use($search) {
try {
$result = $search->search();
return Status::newGood($result);
} catch (ExceptionInterface $e) {
if (strpos($e->getMessage(), 'dynamic scripting for [groovy] disabled')) {
// known issue with default ES config, let's display a more helpful message
return Status::newFatal(new \RawMessage("Couldn't complete search: dynamic scripting needs to be enabled. " . "Please add 'script.disable_dynamic: false' to your elasticsearch.yml"));
}
return Status::newFatal('flow-error-search');
}
}, 'error' => function (Status $status) {
$status = $status->getErrorsArray();
wfLogWarning('Pool error searching Elasticsearch: ' . $status[0][0]);
return Status::newFatal('flow-error-search');
}));
$result = $work->execute();
return $result;
}
示例11: coalesceRuns
/**
* Coalesce consecutive changes by the same user to the same entity into one.
* A run of changes may be broken if the action performed changes (e.g. deletion
* instead of update) or if a sitelink pointing to the local wiki was modified.
*
* Some types of actions, like deletion, will break runs.
* Interleaved changes to different items will break runs.
*
* @param EntityChange[] $changes
*
* @return EntityChange[] grouped changes
*/
private function coalesceRuns(array $changes)
{
$coalesced = array();
$currentRun = array();
$currentUser = null;
$currentEntity = null;
$currentAction = null;
$breakNext = false;
foreach ($changes as $change) {
try {
$action = $change->getAction();
$meta = $change->getMetadata();
$user = $meta['user_text'];
$entityId = $change->getEntityId()->__toString();
$break = $breakNext || $currentAction !== $action || $currentUser !== $user || $currentEntity !== $entityId;
$breakNext = false;
if (!$break && $change instanceof ItemChange) {
$siteLinkDiff = $change->getSiteLinkDiff();
if (isset($siteLinkDiff[$this->localSiteId])) {
// TODO: don't break if only the link's badges changed
$break = true;
$breakNext = true;
}
}
if ($break) {
if (!empty($currentRun)) {
try {
$coalesced[] = $this->mergeChanges($currentRun);
} catch (MWException $ex) {
// Something went wrong while trying to merge the changes.
// Just keep the original run.
wfWarn($ex->getMessage());
$coalesced = array_merge($coalesced, $currentRun);
}
}
$currentRun = array();
$currentUser = $user;
$currentEntity = $entityId;
$currentAction = $action === EntityChange::ADD ? EntityChange::UPDATE : $action;
}
$currentRun[] = $change;
// skip any change that failed to process in some way (bug T51417)
} catch (Exception $ex) {
wfLogWarning(__METHOD__ . ':' . $ex->getMessage());
}
}
if (!empty($currentRun)) {
try {
$coalesced[] = $this->mergeChanges($currentRun);
} catch (MWException $ex) {
// Something went wrong while trying to merge the changes.
// Just keep the original run.
wfWarn($ex->getMessage());
$coalesced = array_merge($coalesced, $currentRun);
}
}
return $coalesced;
}
示例12: fixEditConflict
/**
* Attempts to fix an edit conflict by patching the intended change into the latest revision after
* checking for conflicts. This modifies $this->newEntity but does not write anything to the
* database. Saving of the new content may still fail.
*
* @return bool True if the conflict could be resolved, false otherwise
*/
public function fixEditConflict()
{
$baseRev = $this->getBaseRevision();
$latestRev = $this->getLatestRevision();
if (!$latestRev) {
wfLogWarning('Failed to load latest revision of entity ' . $this->newEntity->getId() . '! ' . 'This may indicate entries missing from thw wb_entities_per_page table.');
return false;
}
$entityDiffer = new EntityDiffer();
$entityPatcher = new EntityPatcher();
// calculate patch against base revision
// NOTE: will fail if $baseRev or $base are null, which they may be if
// this gets called at an inappropriate time. The data flow in this class
// should be improved.
$patch = $entityDiffer->diffEntities($baseRev->getEntity(), $this->newEntity);
if ($patch->isEmpty()) {
// we didn't technically fix anything, but if there is nothing to change,
// so just keep the current content as it is.
$this->newEntity = $latestRev->getEntity()->copy();
return true;
}
// apply the patch( base -> new ) to the latest revision.
$patchedLatest = $latestRev->getEntity()->copy();
$entityPatcher->patchEntity($patchedLatest, $patch);
// detect conflicts against latest revision
$cleanPatch = $entityDiffer->diffEntities($latestRev->getEntity(), $patchedLatest);
$conflicts = $patch->count() - $cleanPatch->count();
if ($conflicts > 0) {
// patch doesn't apply cleanly
if ($this->userWasLastToEdit($this->user, $this->newEntity->getId(), $this->getBaseRevisionId())) {
// it's a self-conflict
if ($cleanPatch->count() === 0) {
// patch collapsed, possibly because of diff operation change from base to latest
return false;
} else {
// we still have a working patch, try to apply
$this->status->warning('wikibase-self-conflict-patched');
}
} else {
// there are unresolvable conflicts.
return false;
}
} else {
// can apply cleanly
$this->status->warning('wikibase-conflict-patched');
}
// remember the patched entity as the actual new entity to save
$this->newEntity = $patchedLatest;
return true;
}
示例13: transformFilePath
/**
* Utility method for transformResourceFilePath().
*
* Caller is responsible for ensuring the file exists. Emits a PHP warning otherwise.
*
* @since 1.27
* @param string $remotePath URL path that points to $localPath
* @param string $localPath File directory exposed at $remotePath
* @param string $file Path to target file relative to $localPath
* @return string URL
*/
public static function transformFilePath($remotePath, $localPath, $file)
{
$hash = md5_file("{$localPath}/{$file}");
if ($hash === false) {
wfLogWarning(__METHOD__ . ": Failed to hash {$localPath}/{$file}");
$hash = '';
}
return "{$remotePath}/{$file}?" . substr($hash, 0, 5);
}
示例14: decompressRevisionText
/**
* Re-converts revision text according to it's flags.
*
* @param mixed $text Reference to a text
* @param array $flags Compression flags
* @return string|bool Decompressed text, or false on failure
*/
public static function decompressRevisionText($text, $flags)
{
if (in_array('gzip', $flags)) {
# Deal with optional compression of archived pages.
# This can be done periodically via maintenance/compressOld.php, and
# as pages are saved if $wgCompressRevisions is set.
$text = gzinflate($text);
if ($text === false) {
wfLogWarning(__METHOD__ . ': gzinflate() failed');
return false;
}
}
if (in_array('object', $flags)) {
# Generic compressed storage
$obj = unserialize($text);
if (!is_object($obj)) {
// Invalid object
return false;
}
$text = $obj->getText();
}
global $wgLegacyEncoding;
if ($text !== false && $wgLegacyEncoding && !in_array('utf-8', $flags) && !in_array('utf8', $flags)) {
# Old revisions kept around in a legacy encoding?
# Upconvert on demand.
# ("utf8" checked for compatibility with some broken
# conversion scripts 2008-12-30)
global $wgContLang;
$text = $wgContLang->iconv($wgLegacyEncoding, 'UTF-8', $text);
}
return $text;
}
示例15: getLegacySkinNames
/**
* @return array
*/
private function getLegacySkinNames()
{
static $skinsInitialised = false;
if (!$skinsInitialised || !count($this->legacySkins)) {
# Get a list of available skins
# Build using the regular expression '^(.*).php$'
# Array keys are all lower case, array value keep the case used by filename
#
wfProfileIn(__METHOD__ . '-init');
global $wgStyleDirectory;
$skinDir = dir($wgStyleDirectory);
if ($skinDir !== false && $skinDir !== null) {
# while code from www.php.net
while (false !== ($file = $skinDir->read())) {
// Skip non-PHP files, hidden files, and '.dep' includes
$matches = array();
if (preg_match('/^([^.]*)\\.php$/', $file, $matches)) {
$aSkin = $matches[1];
// Explicitly disallow loading core skins via the autodiscovery mechanism.
//
// They should be loaded already (in a non-autodicovery way), but old files might still
// exist on the server because our MW version upgrade process is widely documented as
// requiring just copying over all files, without removing old ones.
//
// This is one of the reasons we should have never used autodiscovery in the first
// place. This hack can be safely removed when autodiscovery is gone.
if (in_array($aSkin, array('CologneBlue', 'Modern', 'MonoBook', 'Vector'))) {
wfLogWarning("An old copy of the {$aSkin} skin was found in your skins/ directory. " . "You should remove it to avoid problems in the future." . "See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for details.");
continue;
}
wfLogWarning("A skin using autodiscovery mechanism, {$aSkin}, was found in your skins/ directory. " . "The mechanism will be removed in MediaWiki 1.25 and the skin will no longer be recognized. " . "See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for information how to fix this.");
$this->legacySkins[strtolower($aSkin)] = $aSkin;
}
}
$skinDir->close();
}
$skinsInitialised = true;
wfProfileOut(__METHOD__ . '-init');
}
return $this->legacySkins;
}