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


PHP ParserOptions::legacyOptions方法代码示例

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


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

示例1: getKey

 /**
  * Generates a key for caching the given article considering
  * the given parser options.
  *
  * @note Which parser options influence the cache key
  * is controlled via ParserOutput::recordOption() or
  * ParserOptions::addExtraKey().
  *
  * @note Used by Article to provide a unique id for the PoolCounter.
  * It would be preferable to have this code in get()
  * instead of having Article looking in our internals.
  *
  * @todo Document parameter $useOutdated
  *
  * @param WikiPage $article
  * @param ParserOptions $popts
  * @param bool $useOutdated (default true)
  * @return bool|mixed|string
  */
 public function getKey($article, $popts, $useOutdated = true)
 {
     global $wgCacheEpoch;
     if ($popts instanceof User) {
         wfWarn("Use of outdated prototype ParserCache::getKey( &\$article, &\$user )\n");
         $popts = ParserOptions::newFromUser($popts);
     }
     // Determine the options which affect this article
     $optionsKey = $this->mMemc->get($this->getOptionsKey($article));
     if ($optionsKey instanceof CacheTime) {
         if (!$useOutdated && $optionsKey->expired($article->getTouched())) {
             wfIncrStats("pcache.miss.expired");
             $cacheTime = $optionsKey->getCacheTime();
             wfDebug("Parser options key expired, touched " . $article->getTouched() . ", epoch {$wgCacheEpoch}, cached {$cacheTime}\n");
             return false;
         } elseif ($optionsKey->isDifferentRevision($article->getLatest())) {
             wfIncrStats("pcache.miss.revid");
             $revId = $article->getLatest();
             $cachedRevId = $optionsKey->getCacheRevisionId();
             wfDebug("ParserOutput key is for an old revision, latest {$revId}, cached {$cachedRevId}\n");
             return false;
         }
         // $optionsKey->mUsedOptions is set by save() by calling ParserOutput::getUsedOptions()
         $usedOptions = $optionsKey->mUsedOptions;
         wfDebug("Parser cache options found.\n");
     } else {
         if (!$useOutdated) {
             return false;
         }
         $usedOptions = ParserOptions::legacyOptions();
     }
     return $this->getParserOutputKey($article, $popts->optionsHash($usedOptions, $article->getTitle()));
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:52,代码来源:ParserCache.php

示例2: get

 /**
  * Retrieve the ParserOutput from ParserCache.
  * false if not found or outdated.
  *
  * @param $article Article
  * @param $popts ParserOptions
  * @param $useOutdated
  *
  * @return ParserOutput|false
  */
 public function get($article, $popts, $useOutdated = false)
 {
     global $wgCacheEpoch;
     wfProfileIn(__METHOD__);
     $canCache = $article->checkTouched();
     if (!$canCache) {
         // It's a redirect now
         wfProfileOut(__METHOD__);
         return false;
     }
     $touched = $article->getTouched();
     $parserOutputKey = $this->getKey($article, $popts, $useOutdated);
     if ($parserOutputKey === false) {
         wfIncrStats('pcache_miss_absent');
         wfProfileOut(__METHOD__);
         return false;
     }
     $value = $this->mMemc->get($parserOutputKey);
     if (self::try116cache && !$value && strpos($value, '*') !== -1) {
         wfDebug("New format parser cache miss.\n");
         $parserOutputKey = $this->getParserOutputKey($article, $popts->optionsHash(ParserOptions::legacyOptions(), $article->getTitle()));
         $value = $this->mMemc->get($parserOutputKey);
     }
     if (!$value) {
         wfDebug("ParserOutput cache miss.\n");
         wfIncrStats("pcache_miss_absent");
         wfProfileOut(__METHOD__);
         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());
     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;
     } else {
         wfIncrStats("pcache_hit");
     }
     wfProfileOut(__METHOD__);
     return $value;
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:55,代码来源:ParserCache.php

示例3: getCacheKey

	/**
	 * Get a cache key.
	 *
	 * @param $formId or null
	 * @param Parser $parser or null
	 * @return String
	 */
	public static function getCacheKey( $formId = null, &$parser = null ) {

		if ( is_null( $formId ) ) {
			return wfMemcKey( 'ext.SemanticForms.formdefinition' );
		} elseif ( is_null( $parser ) ) {
			return wfMemcKey( 'ext.SemanticForms.formdefinition', $formId );
		} else {

			if ( method_exists( 'ParserOptions', 'optionsHash' ) ) { // MW 1.17+
				$optionsHash = $parser->getOptions()->optionsHash( ParserOptions::legacyOptions() );
			} else { // MW 1.16
				$optionsHash = $parser->getOptions()->mUser->getPageRenderingHash();
			}

			return wfMemcKey(
					'ext.SemanticForms.formdefinition', $formId, $optionsHash
			);
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:26,代码来源:SF_FormUtils.php

示例4: getCacheKey

 /**
  * Get a cache key.
  *
  * @param $formId or null
  * @param Parser $parser or null
  * @return String
  */
 public static function getCacheKey($formId = null, &$parser = null)
 {
     if (is_null($formId)) {
         return wfMemcKey('ext.SemanticForms.formdefinition');
     } elseif (is_null($parser)) {
         return wfMemcKey('ext.SemanticForms.formdefinition', $formId);
     } else {
         $optionsHash = $parser->getOptions()->optionsHash(ParserOptions::legacyOptions());
         return wfMemcKey('ext.SemanticForms.formdefinition', $formId, $optionsHash);
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:18,代码来源:SF_FormUtils.php

示例5: get

 /**
  * Retrieve the ParserOutput from ParserCache.
  * false if not found or outdated.
  */
 public function get($article, $popts, $useOutdated = false)
 {
     global $wgCacheEpoch;
     wfProfileIn(__METHOD__);
     $canCache = $article->checkTouched();
     if (!$canCache) {
         // It's a redirect now
         wfProfileOut(__METHOD__);
         return false;
     }
     $touched = $article->getTouched();
     $parserOutputKey = $this->getKey($article, $popts, $useOutdated);
     if ($parserOutputKey === false) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $value = $this->mMemc->get($parserOutputKey);
     if (self::try116cache && !$value && strpos($value, '*') !== -1) {
         wfDebug("New format parser cache miss.\n");
         $parserOutputKey = $this->getParserOutputKey($article, $popts->optionsHash(ParserOptions::legacyOptions()));
         $value = $this->mMemc->get($parserOutputKey);
     }
     if (!$value) {
         wfDebug("Parser cache miss.\n");
         wfIncrStats("pcache_miss_absent");
         wfProfileOut(__METHOD__);
         return false;
     }
     wfDebug("Found.\n");
     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;
     } else {
         if (isset($value->mTimestamp)) {
             $article->mTimestamp = $value->mTimestamp;
         }
         wfIncrStats("pcache_hit");
     }
     wfProfileOut(__METHOD__);
     return $value;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:47,代码来源:ParserCache.php


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