当前位置: 首页>>代码示例>>PHP>>正文


PHP WikiPage::checkTouched方法代码示例

本文整理汇总了PHP中WikiPage::checkTouched方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::checkTouched方法的具体用法?PHP WikiPage::checkTouched怎么用?PHP WikiPage::checkTouched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WikiPage的用法示例。


在下文中一共展示了WikiPage::checkTouched方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: view

 /**
  * This is the default action of the index.php entry point: just view the
  * page of the given title.
  */
 public function view()
 {
     global $wgParser, $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
     wfProfileIn(__METHOD__);
     # 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");
         wfProfileOut(__METHOD__);
         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");
         wfProfileOut(__METHOD__);
         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();
         wfProfileOut(__METHOD__);
         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));
         }
         # Is it client cached?
         if ($outputPage->checkLastModified($this->mPage->getTouched())) {
             wfDebug(__METHOD__ . ": done 304\n");
             wfProfileOut(__METHOD__);
             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);
             wfProfileOut(__METHOD__);
             return;
         }
     }
     # Should the parser cache be used?
     $useParserCache = $this->mPage->isParserCacheUsed($parserOptions, $oldid);
     wfDebug('Article::view using parser cache: ' . ($useParserCache ? 'yes' : 'no') . "\n");
     if ($user->getStubThreshold()) {
         wfIncrStats('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:
                 wfRunHooks('ArticleViewHeader', array(&$this, &$outputDone, &$useParserCache));
                 break;
             case 2:
                 # Early abort if the page doesn't exist
                 if (!$this->mPage->exists()) {
                     wfDebug(__METHOD__ . ": showing missing article\n");
                     $this->showMissingArticle();
                     wfProfileOut(__METHOD__);
                     return;
                 }
                 # Try the parser cache
                 if ($useParserCache) {
                     $this->mParserOutput = $parserCache->get($this, $parserOptions);
                     if ($this->mParserOutput !== false) {
//.........这里部分代码省略.........
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:101,代码来源:Article.php

示例2: get

 /**
  * Retrieve the ParserOutput from ParserCache.
  * false if not found or outdated.
  *
  * @param WikiPage|Article $article
  * @param ParserOptions $popts
  * @param bool $useOutdated (default false)
  *
  * @return ParserOutput|bool False on failure
  */
 public function get($article, $popts, $useOutdated = false)
 {
     global $wgCacheEpoch;
     $canCache = $article->checkTouched();
     if (!$canCache) {
         // It's a redirect now
         return false;
     }
     $touched = $article->getTouched();
     $parserOutputKey = $this->getKey($article, $popts, $useOutdated);
     if ($parserOutputKey === false) {
         wfIncrStats('pcache.miss.absent');
         return false;
     }
     $value = $this->mMemc->get($parserOutputKey);
     if (!$value) {
         wfDebug("ParserOutput cache miss.\n");
         wfIncrStats("pcache.miss.absent");
         return false;
     }
     wfDebug("ParserOutput cache found.\n");
     // The edit section preference may not be the appropiate one in
     // the ParserOutput, as we are not storing it in the parsercache
     // key. Force it here. See bug 31445.
     $value->setEditSectionTokens($popts->getEditSection());
     $wikiPage = method_exists($article, 'getPage') ? $article->getPage() : $article;
     if (!$useOutdated && $value->expired($touched)) {
         wfIncrStats("pcache.miss.expired");
         $cacheTime = $value->getCacheTime();
         wfDebug("ParserOutput key expired, touched {$touched}, " . "epoch {$wgCacheEpoch}, cached {$cacheTime}\n");
         $value = false;
     } elseif ($value->isDifferentRevision($article->getLatest())) {
         wfIncrStats("pcache.miss.revid");
         $revId = $article->getLatest();
         $cachedRevId = $value->getCacheRevisionId();
         wfDebug("ParserOutput key is for an old revision, latest {$revId}, cached {$cachedRevId}\n");
         $value = false;
     } elseif (Hooks::run('RejectParserCacheValue', array($value, $wikiPage, $popts)) === false) {
         wfIncrStats('pcache.miss.rejected');
         wfDebug("ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n");
         $value = false;
     } else {
         wfIncrStats("pcache.hit");
     }
     return $value;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:56,代码来源:ParserCache.php

示例3: view

 /**
  * This is the default action of the index.php entry point: just view the
  * page of the given title.
  */
 public function view()
 {
     global $wgUser, $wgOut, $wgRequest, $wgParser;
     global $wgUseFileCache, $wgUseETag;
     wfProfileIn(__METHOD__);
     # Get variables from query string
     $oldid = $this->getOldID();
     # getOldID may want us to redirect somewhere else
     if ($this->mRedirectUrl) {
         $wgOut->redirect($this->mRedirectUrl);
         wfDebug(__METHOD__ . ": redirecting due to oldid\n");
         wfProfileOut(__METHOD__);
         return;
     }
     $wgOut->setArticleFlag(true);
     # Set page title (may be overridden by DISPLAYTITLE)
     $wgOut->setPageTitle($this->getTitle()->getPrefixedText());
     # If we got diff in the query, we want to see a diff page instead of the article.
     if ($wgRequest->getCheck('diff')) {
         wfDebug(__METHOD__ . ": showing diff page\n");
         $this->showDiffPage();
         wfProfileOut(__METHOD__);
         return;
     }
     # Allow frames by default
     $wgOut->allowClickjacking();
     $parserCache = ParserCache::singleton();
     $parserOptions = $this->mPage->getParserOptions();
     # Render printable version, use printable version cache
     if ($wgOut->isPrintable()) {
         $parserOptions->setIsPrintable(true);
         $parserOptions->setEditSection(false);
     } elseif ($wgUseETag && !$this->getTitle()->quickUserCan('edit')) {
         $parserOptions->setEditSection(false);
     }
     # Try client and file cache
     if ($oldid === 0 && $this->mPage->checkTouched()) {
         if ($wgUseETag) {
             $wgOut->setETag($parserCache->getETag($this, $parserOptions));
         }
         # Is it client cached?
         if ($wgOut->checkLastModified($this->mPage->getTouched())) {
             wfDebug(__METHOD__ . ": done 304\n");
             wfProfileOut(__METHOD__);
             return;
             # Try file cache
         } elseif ($wgUseFileCache && $this->tryFileCache()) {
             wfDebug(__METHOD__ . ": done file cache\n");
             # tell wgOut that output is taken care of
             $wgOut->disable();
             $this->mPage->viewUpdates();
             wfProfileOut(__METHOD__);
             return;
         }
     }
     if (!$wgUseETag && !$this->getTitle()->quickUserCan('edit')) {
         $parserOptions->setEditSection(false);
     }
     # Should the parser cache be used?
     $useParserCache = $this->useParserCache($oldid);
     wfDebug('Article::view using parser cache: ' . ($useParserCache ? 'yes' : 'no') . "\n");
     if ($wgUser->getStubThreshold()) {
         wfIncrStats('pcache_miss_stub');
     }
     $wasRedirected = $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:
                 wfRunHooks('ArticleViewHeader', array(&$this, &$outputDone, &$useParserCache));
                 break;
             case 2:
                 # Try the parser cache
                 if ($useParserCache) {
                     $this->mParserOutput = $parserCache->get($this, $parserOptions);
                     if ($this->mParserOutput !== false) {
                         wfDebug(__METHOD__ . ": showing parser cache contents\n");
                         $wgOut->addParserOutput($this->mParserOutput);
                         # Ensure that UI elements requiring revision ID have
                         # the correct version information.
                         $wgOut->setRevisionId($this->mPage->getLatest());
                         $outputDone = true;
                         # Preload timestamp to avoid a DB hit
                         if (isset($this->mParserOutput->mTimestamp)) {
                             $this->mPage->setTimestamp($this->mParserOutput->mTimestamp);
                         }
                     }
                 }
                 break;
             case 3:
                 $text = $this->getContent();
//.........这里部分代码省略.........
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:101,代码来源:Article.php


注:本文中的WikiPage::checkTouched方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。