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


PHP ParserOutput::isCacheable方法代码示例

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


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

示例1: getOutputFromWikitext

 /**
  * This does all the heavy lifting for outputWikitext, except it returns the parser
  * output instead of sending it straight to $wgOut. Makes things nice and simple for,
  * say, embedding thread pages within a discussion system (LiquidThreads)
  *
  * @param $text string
  * @param $cache boolean
  * @param $parserOptions parsing options, defaults to false
  * @return ParserOutput
  */
 public function getOutputFromWikitext($text, $cache = true, $parserOptions = false)
 {
     global $wgParser, $wgEnableParserCache, $wgUseFileCache;
     if (!$parserOptions) {
         $parserOptions = $this->mPage->getParserOptions();
     }
     $time = -wfTime();
     $this->mParserOutput = $wgParser->parse($text, $this->getTitle(), $parserOptions, true, true, $this->getRevIdFetched());
     $time += wfTime();
     # Timing hack
     if ($time > 3) {
         wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->getTitle()->getPrefixedDBkey()));
     }
     if ($wgEnableParserCache && $cache && $this->mParserOutput->isCacheable()) {
         $parserCache = ParserCache::singleton();
         $parserCache->save($this->mParserOutput, $this, $parserOptions);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->mParserOutput->isCacheable() || $this->mParserOutput->containsOldMagic()) {
         $wgUseFileCache = false;
     }
     if ($this->isCurrent()) {
         $this->mPage->doCascadeProtectionUpdates($this->mParserOutput);
     }
     return $this->mParserOutput;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:38,代码来源:Article.php

示例2: doWork

 /**
  * @return bool
  */
 public function doWork()
 {
     global $wgUseFileCache;
     // @todo several of the methods called on $this->page are not declared in Page, but present
     //        in WikiPage and delegated by Article.
     $isCurrent = $this->revid === $this->page->getLatest();
     if ($this->content !== null) {
         $content = $this->content;
     } elseif ($isCurrent) {
         // XXX: why use RAW audience here, and PUBLIC (default) below?
         $content = $this->page->getContent(Revision::RAW);
     } else {
         $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
         if ($rev === null) {
             $content = null;
         } else {
             // XXX: why use PUBLIC audience here (default), and RAW above?
             $content = $rev->getContent();
         }
     }
     if ($content === null) {
         return false;
     }
     // Reduce effects of race conditions for slow parses (bug 46014)
     $cacheTime = wfTimestampNow();
     $time = -microtime(true);
     $this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions);
     $time += microtime(true);
     // Timing hack
     if ($time > 3) {
         // TODO: Use Parser's logger (once it has one)
         $logger = MediaWiki\Logger\LoggerFactory::getInstance('slow-parse');
         $logger->info('{time} {title}', array('time' => number_format($time, 2), 'title' => $this->page->getTitle()->getPrefixedDBkey()));
     }
     if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) {
         ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->parserOutput->isCacheable()) {
         $wgUseFileCache = false;
     }
     if ($isCurrent) {
         $this->page->triggerOpportunisticLinksUpdate($this->parserOutput);
     }
     return true;
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:51,代码来源:PoolWorkArticleView.php

示例3: doWork

 /**
  * @return bool
  */
 public function doWork()
 {
     global $wgUseFileCache;
     // @todo several of the methods called on $this->page are not declared in Page, but present
     //        in WikiPage and delegated by Article.
     $isCurrent = $this->revid === $this->page->getLatest();
     if ($this->content !== null) {
         $content = $this->content;
     } elseif ($isCurrent) {
         // XXX: why use RAW audience here, and PUBLIC (default) below?
         $content = $this->page->getContent(Revision::RAW);
     } else {
         $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
         if ($rev === null) {
             $content = null;
         } else {
             // XXX: why use PUBLIC audience here (default), and RAW above?
             $content = $rev->getContent();
         }
     }
     if ($content === null) {
         return false;
     }
     // Reduce effects of race conditions for slow parses (bug 46014)
     $cacheTime = wfTimestampNow();
     $time = -microtime(true);
     $this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions);
     $time += microtime(true);
     // Timing hack
     if ($time > 3) {
         wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->page->getTitle()->getPrefixedDBkey()));
     }
     if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) {
         ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->parserOutput->isCacheable() || $this->parserOutput->containsOldMagic()) {
         $wgUseFileCache = false;
     }
     if ($isCurrent) {
         $this->page->doCascadeProtectionUpdates($this->parserOutput);
     }
     return true;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:49,代码来源:PoolWorkArticleView.php

示例4: addParserOutputMetadata

 /**
  * Add all metadata associated with a ParserOutput object, but without the actual HTML. This
  * includes categories, language links, ResourceLoader modules, effects of certain magic words,
  * and so on.
  *
  * @since 1.24
  * @param ParserOutput $parserOutput
  */
 public function addParserOutputMetadata($parserOutput)
 {
     $this->mLanguageLinks += $parserOutput->getLanguageLinks();
     $this->addCategoryLinks($parserOutput->getCategories());
     $this->setIndicators($parserOutput->getIndicators());
     $this->mNewSectionLink = $parserOutput->getNewSection();
     $this->mHideNewSectionLink = $parserOutput->getHideNewSection();
     $this->mParseWarnings = $parserOutput->getWarnings();
     if (!$parserOutput->isCacheable()) {
         $this->enableClientCache(false);
     }
     $this->mNoGallery = $parserOutput->getNoGallery();
     $this->mHeadItems = array_merge($this->mHeadItems, $parserOutput->getHeadItems());
     $this->addModules($parserOutput->getModules());
     $this->addModuleScripts($parserOutput->getModuleScripts());
     $this->addModuleStyles($parserOutput->getModuleStyles());
     $this->addJsConfigVars($parserOutput->getJsConfigVars());
     $this->mPreventClickjacking = $this->mPreventClickjacking || $parserOutput->preventClickjacking();
     // Template versioning...
     foreach ((array) $parserOutput->getTemplateIds() as $ns => $dbks) {
         if (isset($this->mTemplateIds[$ns])) {
             $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
         } else {
             $this->mTemplateIds[$ns] = $dbks;
         }
     }
     // File versioning...
     foreach ((array) $parserOutput->getFileSearchOptions() as $dbk => $data) {
         $this->mImageTimeKeys[$dbk] = $data;
     }
     // Hooks registered in the object
     $parserOutputHooks = $this->getConfig()->get('ParserOutputHooks');
     foreach ($parserOutput->getOutputHooks() as $hookInfo) {
         list($hookName, $data) = $hookInfo;
         if (isset($parserOutputHooks[$hookName])) {
             call_user_func($parserOutputHooks[$hookName], $this, $parserOutput, $data);
         }
     }
     // Link flags are ignored for now, but may in the future be
     // used to mark individual language links.
     $linkFlags = array();
     Hooks::run('LanguageLinks', array($this->getTitle(), &$this->mLanguageLinks, &$linkFlags));
     Hooks::run('OutputPageParserOutput', array(&$this, $parserOutput));
 }
开发者ID:GoProjectOwner,项目名称:mediawiki,代码行数:52,代码来源:OutputPage.php

示例5: doWork

 /**
  * @return bool
  */
 function doWork()
 {
     global $wgParser, $wgUseFileCache;
     $isCurrent = $this->revid === $this->page->getLatest();
     if ($this->text !== null) {
         $text = $this->text;
     } elseif ($isCurrent) {
         $text = $this->page->getRawText();
     } else {
         $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
         if ($rev === null) {
             return false;
         }
         $text = $rev->getText();
     }
     $time = -microtime(true);
     $this->parserOutput = $wgParser->parse($text, $this->page->getTitle(), $this->parserOptions, true, true, $this->revid);
     $time += microtime(true);
     # Timing hack
     if ($time > 3) {
         wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->page->getTitle()->getPrefixedDBkey()));
     }
     if ($this->cacheable && $this->parserOutput->isCacheable()) {
         ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->parserOutput->isCacheable() || $this->parserOutput->containsOldMagic()) {
         $wgUseFileCache = false;
     }
     if ($isCurrent) {
         $this->page->doCascadeProtectionUpdates($this->parserOutput);
     }
     return true;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:39,代码来源:WikiPage.php


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