本文整理汇总了PHP中ParserCache类的典型用法代码示例。如果您正苦于以下问题:PHP ParserCache类的具体用法?PHP ParserCache怎么用?PHP ParserCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParserCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
global $wgContLang, $wgUser, $wgLanguageCode;
$wgContLang = Language::factory($wgLanguageCode);
$this->popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
$this->pcache = ParserCache::singleton();
}
示例2: getSequenceSMIL
/**
* returns the xml output of the sequence with all wiki-text templates/magic words swapped out
* also resolves all image and media locations with absolute paths.
*/
function getSequenceSMIL()
{
global $wgParser, $wgOut, $wgUser, $wgEnableParserCache;
//temporally stop cache:
$wgEnableParserCache = false;
$parserOptions = ParserOptions::newFromUser($wgUser);
$parserOptions->addExtraKey('mv:seq-xml');
//differentiate the articles xml from article
if ($wgEnableParserCache) {
$mvParserCache = ParserCache::singleton();
$parserOutput = $mvParserCache->get($this, $parserOptions);
if ($parserOutput != false) {
return $parserOutput->getText();
}
}
//get the high level sequence description:
$this->getSequenceHLRD();
$this->parseHLRD_DOM();
//this is the heavy lifting of the getSequenceSMIL function:
$this->resolveHLRD_to_SMIL();
//@@todo get parser Output Object (maybe cleaner way to do this?
//maybe parser cache is not the right place to cache the sequence xml? )
$parserOutput = $wgParser->parse('', $this->mTitle, $parserOptions);
//output header:
$parserOutput->mText .= $this->smilDoc->saveXML();
//save to cache if parser cache enabled:
if ($wgEnableParserCache) {
$mvParserCache->save($parserOutput, $this, $parserOptions);
}
return $parserOutput->getText();
}
示例3: execute
/**
* Purges the cache of a page
*/
public function execute()
{
$params = $this->extractRequestParams();
$continuationManager = new ApiContinuationManager($this, array(), array());
$this->setContinuationManager($continuationManager);
$forceLinkUpdate = $params['forcelinkupdate'];
$forceRecursiveLinkUpdate = $params['forcerecursivelinkupdate'];
$pageSet = $this->getPageSet();
$pageSet->execute();
$result = $pageSet->getInvalidTitlesAndRevisions();
foreach ($pageSet->getGoodTitles() as $title) {
$r = array();
ApiQueryBase::addTitleInfo($r, $title);
$page = WikiPage::factory($title);
$page->doPurge();
// Directly purge and skip the UI part of purge().
$r['purged'] = true;
if ($forceLinkUpdate || $forceRecursiveLinkUpdate) {
if (!$this->getUser()->pingLimiter('linkpurge')) {
$popts = $page->makeParserOptions('canonical');
# Parse content; note that HTML generation is only needed if we want to cache the result.
$content = $page->getContent(Revision::RAW);
$enableParserCache = $this->getConfig()->get('EnableParserCache');
$p_result = $content->getParserOutput($title, $page->getLatest(), $popts, $enableParserCache);
# Update the links tables
$updates = $content->getSecondaryDataUpdates($title, null, $forceRecursiveLinkUpdate, $p_result);
DataUpdate::runUpdates($updates);
$r['linkupdate'] = true;
if ($enableParserCache) {
$pcache = ParserCache::singleton();
$pcache->save($p_result, $page, $popts);
}
} else {
$error = $this->parseMsg(array('actionthrottledtext'));
$this->setWarning($error['info']);
$forceLinkUpdate = false;
}
}
$result[] = $r;
}
$apiResult = $this->getResult();
ApiResult::setIndexedTagName($result, 'page');
$apiResult->addValue(null, $this->getModuleName(), $result);
$values = $pageSet->getNormalizedTitlesAsResult($apiResult);
if ($values) {
$apiResult->addValue(null, 'normalized', $values);
}
$values = $pageSet->getConvertedTitlesAsResult($apiResult);
if ($values) {
$apiResult->addValue(null, 'converted', $values);
}
$values = $pageSet->getRedirectTitlesAsResult($apiResult);
if ($values) {
$apiResult->addValue(null, 'redirects', $values);
}
$this->setContinuationManager(null);
$continuationManager->setContinuationIntoResult($apiResult);
}
示例4: getRevIncludes
/**
* Get template and image versions from parsing a revision
* @param Page $article
* @param Revision $rev
* @param User $user
* @param string $regen use 'regen' to force regeneration
* @return array( templateIds, fileSHA1Keys )
* templateIds like ParserOutput->mTemplateIds
* fileSHA1Keys like ParserOutput->mImageTimeKeys
*/
public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
{
global $wgParser, $wgMemc;
wfProfileIn(__METHOD__);
$versions = false;
$key = self::getCacheKey($article->getTitle(), $rev->getId());
if ($regen !== 'regen') {
// check cache
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
}
if (!is_array($versions)) {
// cache miss
$pOut = false;
if ($rev->isCurrent()) {
$parserCache = ParserCache::singleton();
# Try current version parser cache (as anon)...
$pOut = $parserCache->get($article, $article->makeParserOptions($user));
if ($pOut == false && $rev->getUser()) {
// try the user who saved the change
$author = User::newFromId($rev->getUser());
$pOut = $parserCache->get($article, $article->makeParserOptions($author));
}
}
// ParserOutput::mImageTimeKeys wasn't always there
if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
$title = $article->getTitle();
$pOpts = ParserOptions::newFromUser($user);
// Note: tidy off
$pOut = $wgParser->parse($rev->getText(), $title, $pOpts, true, true, $rev->getId());
}
# Get the template/file versions used...
$versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
# Save to cache (check cache expiry for dynamic elements)...
$data = FlaggedRevs::makeMemcObj($versions);
$wgMemc->set($key, $data, $pOut->getCacheExpiry());
} else {
$tVersions =& $versions[0];
// templates
# Do a link batch query for page_latest...
$lb = new LinkBatch();
foreach ($tVersions as $ns => $tmps) {
foreach ($tmps as $dbKey => $revIdDraft) {
$lb->add($ns, $dbKey);
}
}
$lb->execute();
# Update array with the current page_latest values.
# This kludge is there since $newTemplates (thus $revIdDraft) is cached.
foreach ($tVersions as $ns => &$tmps) {
foreach ($tmps as $dbKey => &$revIdDraft) {
$title = Title::makeTitle($ns, $dbKey);
$revIdDraft = (int) $title->getLatestRevID();
}
}
}
wfProfileOut(__METHOD__);
return $versions;
}
示例5: getRevIncludes
/**
* Get template and image versions from parsing a revision
* @param Page $article
* @param Revision $rev
* @param User $user
* @param string $regen use 'regen' to force regeneration
* @return array( templateIds, fileSHA1Keys )
* templateIds like ParserOutput->mTemplateIds
* fileSHA1Keys like ParserOutput->mImageTimeKeys
*/
public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
{
global $wgMemc;
wfProfileIn(__METHOD__);
$key = self::getCacheKey($article->getTitle(), $rev->getId());
if ($regen === 'regen') {
$versions = false;
// skip cache
} elseif ($rev->isCurrent()) {
// Check cache entry against page_touched
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article);
} else {
// Old revs won't always be invalidated with template/file changes.
// Also, we don't care if page_touched changed due to a direct edit.
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
if (is_array($versions)) {
// entry exists
// Sanity check that the cache is reasonably up to date
list($templates, $files) = $versions;
if (self::templatesStale($templates) || self::filesStale($files)) {
$versions = false;
// no good
}
}
}
if (!is_array($versions)) {
// cache miss
$pOut = false;
if ($rev->isCurrent()) {
$parserCache = ParserCache::singleton();
# Try current version parser cache for this user...
$pOut = $parserCache->get($article, $article->makeParserOptions($user));
if ($pOut == false) {
# Try current version parser cache for the revision author...
$optsUser = $rev->getUser() ? User::newFromId($rev->getUser()) : 'canonical';
$pOut = $parserCache->get($article, $article->makeParserOptions($optsUser));
}
}
// ParserOutput::mImageTimeKeys wasn't always there
if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
$content = $rev->getContent(Revision::RAW);
if (!$content) {
// Just for extra sanity
$pOut = new ParserOutput();
} else {
$pOut = $content->getParserOutput($article->getTitle(), $rev->getId(), ParserOptions::newFromUser($user));
}
}
# Get the template/file versions used...
$versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
# Save to cache (check cache expiry for dynamic elements)...
$data = FlaggedRevs::makeMemcObj($versions);
$wgMemc->set($key, $data, $pOut->getCacheExpiry());
}
wfProfileOut(__METHOD__);
return $versions;
}
示例6: setUp
protected function setUp()
{
global $wgLanguageCode, $wgUser;
parent::setUp();
$langObj = Language::factory($wgLanguageCode);
$this->setMwGlobals(array('wgContLang' => $langObj, 'wgUseDynamicDates' => true));
$this->popts = ParserOptions::newFromUserAndLang($wgUser, $langObj);
$this->pcache = ParserCache::singleton();
}
示例7: setUp
function setUp()
{
ParserTest::setUp();
//reuse setup from parser tests
global $wgContLang, $wgUser, $wgLanguageCode;
$wgContLang = Language::factory($wgLanguageCode);
$this->popts = new ParserOptions($wgUser);
$this->pcache = ParserCache::singleton();
}
示例8: execute
/**
* Purges the cache of a page
*/
public function execute()
{
global $wgUser;
$params = $this->extractRequestParams();
if (!$wgUser->isAllowed('purge') && !$this->getMain()->isInternalMode() && !$this->getMain()->getRequest()->wasPosted()) {
$this->dieUsageMsg(array('mustbeposted', $this->getModuleName()));
}
$forceLinkUpdate = $params['forcelinkupdate'];
$result = array();
foreach ($params['titles'] as $t) {
$r = array();
$title = Title::newFromText($t);
if (!$title instanceof Title) {
$r['title'] = $t;
$r['invalid'] = '';
$result[] = $r;
continue;
}
ApiQueryBase::addTitleInfo($r, $title);
if (!$title->exists()) {
$r['missing'] = '';
$result[] = $r;
continue;
}
$context = $this->createContext();
$context->setTitle($title);
$article = Article::newFromTitle($title, $context);
$article->doPurge();
// Directly purge and skip the UI part of purge().
$r['purged'] = '';
if ($forceLinkUpdate) {
if (!$wgUser->pingLimiter()) {
global $wgParser, $wgEnableParserCache;
$popts = new ParserOptions();
$p_result = $wgParser->parse($article->getContent(), $title, $popts);
# Update the links tables
$u = new LinksUpdate($title, $p_result);
$u->doUpdate();
$r['linkupdate'] = '';
if ($wgEnableParserCache) {
$pcache = ParserCache::singleton();
$pcache->save($p_result, $article, $popts);
}
} else {
$this->setWarning($this->parseMsg(array('actionthrottledtext')));
$forceLinkUpdate = false;
}
}
$result[] = $r;
}
$apiResult = $this->getResult();
$apiResult->setIndexedTagName($result, 'page');
$apiResult->addValue(null, $this->getModuleName(), $result);
}
示例9: execute
public function execute()
{
$pages = $this->getOption('maxpages');
$dbr = $this->getDB(DB_REPLICA);
$totalsec = 0.0;
$scanned = 0;
$withcache = 0;
$withdiff = 0;
while ($pages-- > 0) {
$row = $dbr->selectRow('page', '*', ['page_namespace' => $this->getOption('namespace'), 'page_is_redirect' => 0, 'page_random >= ' . wfRandom()], __METHOD__, ['ORDER BY' => 'page_random']);
if (!$row) {
continue;
}
++$scanned;
$title = Title::newFromRow($row);
$page = WikiPage::factory($title);
$revision = $page->getRevision();
$content = $revision->getContent(Revision::RAW);
$parserOptions = $page->makeParserOptions('canonical');
$parserOutputOld = ParserCache::singleton()->get($page, $parserOptions);
if ($parserOutputOld) {
$t1 = microtime(true);
$parserOutputNew = $content->getParserOutput($title, $revision->getId(), $parserOptions, false);
$sec = microtime(true) - $t1;
$totalsec += $sec;
$this->output("Parsed '{$title->getPrefixedText()}' in {$sec} seconds.\n");
$this->output("Found cache entry found for '{$title->getPrefixedText()}'...");
$oldHtml = trim(preg_replace('#<!-- .+-->#Us', '', $parserOutputOld->getText()));
$newHtml = trim(preg_replace('#<!-- .+-->#Us', '', $parserOutputNew->getText()));
$diff = wfDiff($oldHtml, $newHtml);
if (strlen($diff)) {
$this->output("differences found:\n\n{$diff}\n\n");
++$withdiff;
} else {
$this->output("No differences found.\n");
}
++$withcache;
} else {
$this->output("No parser cache entry found for '{$title->getPrefixedText()}'.\n");
}
}
$ave = $totalsec ? $totalsec / $scanned : 0;
$this->output("Checked {$scanned} pages; {$withcache} had prior cache entries.\n");
$this->output("Pages with differences found: {$withdiff}\n");
$this->output("Average parse time: {$ave} sec\n");
}
示例10: getText
protected function getText($title)
{
$titleObject = Title::newFromText($title);
$article = new Article($titleObject);
// make sure the article exists.
if ($article->getId() == 0) {
return null;
}
// prepare the parser cache for action.
$parserCache =& ParserCache::singleton();
global $wgUser;
$parserOutput = $parserCache->get($article, $wgUser);
// did we find it in the parser cache?
if ($parserOutput !== false) {
return $parserOutput->getText();
}
// no... that's too bad; go the long way then.
$rev = Revision::newFromTitle($titleObject);
if (is_object($rev)) {
return $this->parse($titleObject, $rev->getText());
}
return null;
}
示例11: fallback
/**
* @return bool
*/
function fallback() {
$this->parserOutput = ParserCache::singleton()->getDirty( $this->page, $this->parserOptions );
if ( $this->parserOutput === false ) {
wfDebugLog( 'dirty', "dirty missing\n" );
wfDebug( __METHOD__ . ": no dirty cache\n" );
return false;
} else {
wfDebug( __METHOD__ . ": sending dirty output\n" );
wfDebugLog( 'dirty', "dirty output {$this->cacheKey}\n" );
$this->isDirty = true;
return true;
}
}
示例12: view
/**
* This is the default action of the index.php entry point: just view the
* page of the given title.
*/
public function view()
{
global $wgUseFileCache, $wgUseETag, $wgDebugToolbar, $wgMaxRedirects;
# Get variables from query string
# As side effect this will load the revision and update the title
# in a revision ID is passed in the request, so this should remain
# the first call of this method even if $oldid is used way below.
$oldid = $this->getOldID();
$user = $this->getContext()->getUser();
# Another whitelist check in case getOldID() is altering the title
$permErrors = $this->getTitle()->getUserPermissionsErrors('read', $user);
if (count($permErrors)) {
wfDebug(__METHOD__ . ": denied on secondary read check\n");
throw new PermissionsError('read', $permErrors);
}
$outputPage = $this->getContext()->getOutput();
# getOldID() may as well want us to redirect somewhere else
if ($this->mRedirectUrl) {
$outputPage->redirect($this->mRedirectUrl);
wfDebug(__METHOD__ . ": redirecting due to oldid\n");
return;
}
# If we got diff in the query, we want to see a diff page instead of the article.
if ($this->getContext()->getRequest()->getCheck('diff')) {
wfDebug(__METHOD__ . ": showing diff page\n");
$this->showDiffPage();
return;
}
# Set page title (may be overridden by DISPLAYTITLE)
$outputPage->setPageTitle($this->getTitle()->getPrefixedText());
$outputPage->setArticleFlag(true);
# Allow frames by default
$outputPage->allowClickjacking();
$parserCache = ParserCache::singleton();
$parserOptions = $this->getParserOptions();
# Render printable version, use printable version cache
if ($outputPage->isPrintable()) {
$parserOptions->setIsPrintable(true);
$parserOptions->setEditSection(false);
} elseif (!$this->isCurrent() || !$this->getTitle()->quickUserCan('edit', $user)) {
$parserOptions->setEditSection(false);
}
# Try client and file cache
if (!$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched()) {
if ($wgUseETag) {
$outputPage->setETag($parserCache->getETag($this, $parserOptions));
}
# Use the greatest of the page's timestamp or the timestamp of any
# redirect in the chain (bug 67849)
$timestamp = $this->mPage->getTouched();
if (isset($this->mRedirectedFrom)) {
$timestamp = max($timestamp, $this->mRedirectedFrom->getTouched());
# If there can be more than one redirect in the chain, we have
# to go through the whole chain too in case an intermediate
# redirect was changed.
if ($wgMaxRedirects > 1) {
$titles = Revision::newFromTitle($this->mRedirectedFrom)->getContent(Revision::FOR_THIS_USER, $user)->getRedirectChain();
$thisTitle = $this->getTitle();
foreach ($titles as $title) {
if (Title::compare($title, $thisTitle) === 0) {
break;
}
$timestamp = max($timestamp, $title->getTouched());
}
}
}
# Is it client cached?
if ($outputPage->checkLastModified($timestamp)) {
wfDebug(__METHOD__ . ": done 304\n");
return;
# Try file cache
} elseif ($wgUseFileCache && $this->tryFileCache()) {
wfDebug(__METHOD__ . ": done file cache\n");
# tell wgOut that output is taken care of
$outputPage->disable();
$this->mPage->doViewUpdates($user, $oldid);
return;
}
}
# Should the parser cache be used?
$useParserCache = $this->mPage->shouldCheckParserCache($parserOptions, $oldid);
wfDebug('Article::view using parser cache: ' . ($useParserCache ? 'yes' : 'no') . "\n");
if ($user->getStubThreshold()) {
$this->getContext()->getStats()->increment('pcache_miss_stub');
}
$this->showRedirectedFromHeader();
$this->showNamespaceHeader();
# Iterate through the possible ways of constructing the output text.
# Keep going until $outputDone is set, or we run out of things to do.
$pass = 0;
$outputDone = false;
$this->mParserOutput = false;
while (!$outputDone && ++$pass) {
switch ($pass) {
case 1:
Hooks::run('ArticleViewHeader', array(&$this, &$outputDone, &$useParserCache));
//.........这里部分代码省略.........
示例13: execute
public function execute()
{
// The data is hot but user-dependent, like page views, so we set vary cookies
$this->getMain()->setCacheMode('anon-public-user-private');
// Get parameters
$params = $this->extractRequestParams();
$text = $params['text'];
$title = $params['title'];
$page = $params['page'];
$oldid = $params['oldid'];
if (!is_null($page) && (!is_null($text) || $title != "API")) {
$this->dieUsage("The page parameter cannot be used together with the text and title parameters", 'params');
}
$prop = array_flip($params['prop']);
$revid = false;
// The parser needs $wgTitle to be set, apparently the
// $title parameter in Parser::parse isn't enough *sigh*
global $wgParser, $wgUser, $wgTitle, $wgEnableParserCache;
$popts = new ParserOptions();
$popts->setTidy(true);
$popts->enableLimitReport();
$redirValues = null;
if (!is_null($oldid) || !is_null($page)) {
if (!is_null($oldid)) {
// Don't use the parser cache
$rev = Revision::newFromID($oldid);
if (!$rev) {
$this->dieUsage("There is no revision ID {$oldid}", 'missingrev');
}
if (!$rev->userCan(Revision::DELETED_TEXT)) {
$this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied');
}
$text = $rev->getText(Revision::FOR_THIS_USER);
$titleObj = $rev->getTitle();
$wgTitle = $titleObj;
$p_result = $wgParser->parse($text, $titleObj, $popts);
} else {
if ($params['redirects']) {
$req = new FauxRequest(array('action' => 'query', 'redirects' => '', 'titles' => $page));
$main = new ApiMain($req);
$main->execute();
$data = $main->getResultData();
$redirValues = @$data['query']['redirects'];
$to = $page;
foreach ((array) $redirValues as $r) {
$to = $r['to'];
}
} else {
$to = $page;
}
$titleObj = Title::newFromText($to);
if (!$titleObj) {
$this->dieUsage("The page you specified doesn't exist", 'missingtitle');
}
$articleObj = new Article($titleObj);
if (isset($prop['revid'])) {
$oldid = $articleObj->getRevIdFetched();
}
// Try the parser cache first
$p_result = false;
$pcache = ParserCache::singleton();
if ($wgEnableParserCache) {
$p_result = $pcache->get($articleObj, $wgUser);
}
if (!$p_result) {
$p_result = $wgParser->parse($articleObj->getContent(), $titleObj, $popts);
if ($wgEnableParserCache) {
$pcache->save($p_result, $articleObj, $popts);
}
}
}
} else {
$titleObj = Title::newFromText($title);
if (!$titleObj) {
$titleObj = Title::newFromText("API");
}
$wgTitle = $titleObj;
if ($params['pst'] || $params['onlypst']) {
$text = $wgParser->preSaveTransform($text, $titleObj, $wgUser, $popts);
}
if ($params['onlypst']) {
// Build a result and bail out
$result_array['text'] = array();
$this->getResult()->setContent($result_array['text'], $text);
$this->getResult()->addValue(null, $this->getModuleName(), $result_array);
return;
}
$p_result = $wgParser->parse($text, $titleObj, $popts);
}
// Return result
$result = $this->getResult();
$result_array = array();
if ($params['redirects'] && !is_null($redirValues)) {
$result_array['redirects'] = $redirValues;
}
if (isset($prop['text'])) {
$result_array['text'] = array();
$result->setContent($result_array['text'], $p_result->getText());
}
if (!is_null($params['summary'])) {
//.........这里部分代码省略.........
示例14: doEditUpdates
/**
* Do standard deferred updates after page edit.
* Update links tables, site stats, search index and message cache.
* Purges pages that include this page if the text was changed here.
* Every 100th edit, prune the recent changes table.
*
* @param Revision $revision
* @param User $user User object that did the revision
* @param array $options Array of options, following indexes are used:
* - changed: boolean, whether the revision changed the content (default true)
* - created: boolean, whether the revision created the page (default false)
* - moved: boolean, whether the page was moved (default false)
* - oldcountable: boolean, null, or string 'no-change' (default null):
* - boolean: whether the page was counted as an article before that
* revision, only used in changed is true and created is false
* - null: if created is false, don't update the article count; if created
* is true, do update the article count
* - 'no-change': don't update the article count, ever
*/
public function doEditUpdates(Revision $revision, User $user, array $options = array())
{
$options += array('changed' => true, 'created' => false, 'moved' => false, 'oldcountable' => null);
$content = $revision->getContent();
// Parse the text
// Be careful not to do pre-save transform twice: $text is usually
// already pre-save transformed once.
if (!$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag('vary-revision')) {
wfDebug(__METHOD__ . ": No prepared edit or vary-revision is set...\n");
$editInfo = $this->prepareContentForEdit($content, $revision, $user);
} else {
wfDebug(__METHOD__ . ": No vary-revision, using prepared edit...\n");
$editInfo = $this->mPreparedEdit;
}
// Save it to the parser cache.
// Make sure the cache time matches page_touched to avoid double parsing.
ParserCache::singleton()->save($editInfo->output, $this, $editInfo->popts, $revision->getTimestamp(), $editInfo->revid);
// Update the links tables and other secondary data
if ($content) {
$recursive = $options['changed'];
// bug 50785
$updates = $content->getSecondaryDataUpdates($this->getTitle(), null, $recursive, $editInfo->output);
foreach ($updates as $update) {
if ($update instanceof LinksUpdate) {
$update->setRevision($revision);
}
DeferredUpdates::addUpdate($update);
}
}
Hooks::run('ArticleEditUpdates', array(&$this, &$editInfo, $options['changed']));
if (Hooks::run('ArticleEditUpdatesDeleteFromRecentchanges', array(&$this))) {
// Flush old entries from the `recentchanges` table
if (mt_rand(0, 9) == 0) {
JobQueueGroup::singleton()->lazyPush(RecentChangesUpdateJob::newPurgeJob());
}
}
if (!$this->exists()) {
return;
}
$id = $this->getId();
$title = $this->mTitle->getPrefixedDBkey();
$shortTitle = $this->mTitle->getDBkey();
if ($options['oldcountable'] === 'no-change' || !$options['changed'] && !$options['moved']) {
$good = 0;
} elseif ($options['created']) {
$good = (int) $this->isCountable($editInfo);
} elseif ($options['oldcountable'] !== null) {
$good = (int) $this->isCountable($editInfo) - (int) $options['oldcountable'];
} else {
$good = 0;
}
$edits = $options['changed'] ? 1 : 0;
$total = $options['created'] ? 1 : 0;
DeferredUpdates::addUpdate(new SiteStatsUpdate(0, $edits, $good, $total));
DeferredUpdates::addUpdate(new SearchUpdate($id, $title, $content));
// If this is another user's talk page, update newtalk.
// Don't do this if $options['changed'] = false (null-edits) nor if
// it's a minor edit and the user doesn't want notifications for those.
if ($options['changed'] && $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $user->getTitleKey() && !($revision->isMinor() && $user->isAllowed('nominornewtalk'))) {
$recipient = User::newFromName($shortTitle, false);
if (!$recipient) {
wfDebug(__METHOD__ . ": invalid username\n");
} else {
// Allow extensions to prevent user notification
// when a new message is added to their talk page
if (Hooks::run('ArticleEditUpdateNewTalk', array(&$this, $recipient))) {
if (User::isIP($shortTitle)) {
// An anonymous user
$recipient->setNewtalk(true, $revision);
} elseif ($recipient->isLoggedIn()) {
$recipient->setNewtalk(true, $revision);
} else {
wfDebug(__METHOD__ . ": don't need to notify a nonexistent user\n");
}
}
}
}
if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
// XXX: could skip pseudo-messages like js/css here, based on content model.
$msgtext = $content ? $content->getWikitextForTransclusion() : null;
if ($msgtext === false || $msgtext === null) {
//.........这里部分代码省略.........
示例15: tryParserCache
/**
* @param Article $article
* @param User $user
*
* @return bool True if successful, else false.
*/
public function tryParserCache(&$article, $user)
{
$parserCache = ParserCache::singleton();
$parserOutput = $parserCache->get($article, $user);
if ($parserOutput !== false) {
$this->addParserOutput($parserOutput);
return true;
} else {
return false;
}
}