• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfIncrStats函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wfIncrStats函数的典型用法代码示例。如果您正苦于以下问题:PHP wfIncrStats函数的具体用法?PHP wfIncrStats怎么用?PHP wfIncrStats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: getLagTimes

 function getLagTimes($serverIndexes, $wiki)
 {
     wfProfileIn(__METHOD__);
     $expiry = 5;
     $requestRate = 10;
     global $wgMemc;
     if (empty($wgMemc)) {
         $wgMemc = wfGetMainCache();
     }
     $masterName = $this->parent->getServerName(0);
     $memcKey = wfMemcKey('lag_times', $masterName);
     $times = $wgMemc->get($memcKey);
     if ($times) {
         # Randomly recache with probability rising over $expiry
         $elapsed = time() - $times['timestamp'];
         $chance = max(0, ($expiry - $elapsed) * $requestRate);
         if (mt_rand(0, $chance) != 0) {
             unset($times['timestamp']);
             wfProfileOut(__METHOD__);
             return $times;
         }
         wfIncrStats('lag_cache_miss_expired');
     } else {
         wfIncrStats('lag_cache_miss_absent');
     }
     # Cache key missing or expired
     $times = array();
     foreach ($serverIndexes as $i) {
         if ($i == 0) {
             # Master
             $times[$i] = 0;
         } elseif (false !== ($conn = $this->parent->getAnyOpenConnection($i))) {
             $times[$i] = $conn->getLag();
         } elseif (false !== ($conn = $this->parent->openConnection($i, $wiki))) {
             $times[$i] = $conn->getLag();
         }
     }
     # Add a timestamp key so we know when it was cached
     $times['timestamp'] = time();
     $wgMemc->set($memcKey, $times, $expiry);
     # But don't give the timestamp to the caller
     unset($times['timestamp']);
     $lagTimes = $times;
     wfProfileOut(__METHOD__);
     return $lagTimes;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:46,代码来源:LoadMonitor.php


示例2: get

 function get(&$article, &$user)
 {
     global $wgCacheEpoch;
     $fname = 'ParserCache::get';
     wfProfileIn($fname);
     $key = $this->getKey($article, $user);
     wfDebug("Trying parser cache {$key}\n");
     $value = $this->mMemc->get($key);
     if (is_object($value)) {
         wfDebug("Found.\n");
         # Delete if article has changed since the cache was made
         $canCache = $article->checkTouched();
         $cacheTime = $value->getCacheTime();
         $touched = $article->mTouched;
         if (!$canCache || $value->expired($touched)) {
             if (!$canCache) {
                 wfIncrStats("pcache_miss_invalid");
                 wfDebug("Invalid cached redirect, touched {$touched}, epoch {$wgCacheEpoch}, cached {$cacheTime}\n");
             } else {
                 wfIncrStats("pcache_miss_expired");
                 wfDebug("Key expired, touched {$touched}, epoch {$wgCacheEpoch}, cached {$cacheTime}\n");
             }
             $this->mMemc->delete($key);
             $value = false;
         } else {
             if (isset($value->mTimestamp)) {
                 $article->mTimestamp = $value->mTimestamp;
             }
             wfIncrStats("pcache_hit");
         }
     } else {
         wfDebug("Parser cache miss.\n");
         wfIncrStats("pcache_miss_absent");
         $value = false;
     }
     wfProfileOut($fname);
     return $value;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:38,代码来源:ParserCache.php


示例3: loadFromCache

 /**
  * Try to load file metadata from memcached. Returns true on success.
  * @return bool
  */
 function loadFromCache()
 {
     $this->dataLoaded = false;
     $this->extraDataLoaded = false;
     $key = $this->getCacheKey();
     if (!$key) {
         return false;
     }
     $cache = ObjectCache::getMainWANInstance();
     $cachedValues = $cache->get($key);
     // Check if the key existed and belongs to this version of MediaWiki
     if (is_array($cachedValues) && $cachedValues['version'] == MW_FILE_VERSION) {
         $this->fileExists = $cachedValues['fileExists'];
         if ($this->fileExists) {
             $this->setProps($cachedValues);
         }
         $this->dataLoaded = true;
         $this->extraDataLoaded = true;
         foreach ($this->getLazyCacheFields('') as $field) {
             $this->extraDataLoaded = $this->extraDataLoaded && isset($cachedValues[$field]);
         }
     }
     if ($this->dataLoaded) {
         wfIncrStats('image_cache.hit');
     } else {
         wfIncrStats('image_cache.miss');
     }
     return $this->dataLoaded;
 }
开发者ID:paladox,项目名称:2,代码行数:33,代码来源:LocalFile.php


示例4: removeDuplicates

 /**
  * Remove jobs in the job queue which are duplicates of this job.
  * This is deadlock-prone and so starts its own transaction.
  */
 function removeDuplicates()
 {
     if (!$this->removeDuplicates) {
         return;
     }
     $fields = $this->insertFields();
     unset($fields['job_id']);
     $dbw = wfGetDB(DB_MASTER);
     $dbw->begin(__METHOD__);
     $dbw->delete('job', $fields, __METHOD__);
     $affected = $dbw->affectedRows();
     $dbw->commit(__METHOD__);
     if ($affected) {
         wfIncrStats('job-dup-delete', $affected);
     }
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:20,代码来源:Job.php


示例5: addWikiTextTitle

 public function addWikiTextTitle($text, &$title, $linestart, $tidy = false)
 {
     global $wgParser;
     wfProfileIn(__METHOD__);
     wfIncrStats('pcache_not_possible');
     $popts = $this->parserOptions();
     $oldTidy = $popts->setTidy($tidy);
     $parserOutput = $wgParser->parse($text, $title, $popts, $linestart, true, $this->mRevisionId);
     $popts->setTidy($oldTidy);
     $this->addParserOutput($parserOutput);
     wfProfileOut(__METHOD__);
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:12,代码来源:OutputPage.php


示例6: getParserOutput

 /**
  * Get a ParserOutput for the given ParserOptions and revision ID.
  *
  * The parser cache will be used if possible. Cache misses that result
  * in parser runs are debounced with PoolCounter.
  *
  * @since 1.19
  * @param ParserOptions $parserOptions ParserOptions to use for the parse operation
  * @param null|int      $oldid Revision ID to get the text from, passing null or 0 will
  *                             get the current revision (default value)
  * @param bool          $forceParse Force reindexing, regardless of cache settings
  * @return bool|ParserOutput ParserOutput or false if the revision was not found
  */
 public function getParserOutput(ParserOptions $parserOptions, $oldid = null, $forceParse = false)
 {
     $useParserCache = !$forceParse && $this->shouldCheckParserCache($parserOptions, $oldid);
     wfDebug(__METHOD__ . ': using parser cache: ' . ($useParserCache ? 'yes' : 'no') . "\n");
     if ($parserOptions->getStubThreshold()) {
         wfIncrStats('pcache.miss.stub');
     }
     if ($useParserCache) {
         $parserOutput = ParserCache::singleton()->get($this, $parserOptions);
         if ($parserOutput !== false) {
             return $parserOutput;
         }
     }
     if ($oldid === null || $oldid === 0) {
         $oldid = $this->getLatest();
     }
     $pool = new PoolWorkArticleView($this, $parserOptions, $oldid, $useParserCache);
     $pool->execute();
     return $pool->getParserOutput();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:33,代码来源:WikiPage.php


示例7: addWikiTextTitle

 function addWikiTextTitle($text, &$title, $linestart)
 {
     global $wgParser;
     $fname = 'OutputPage:addWikiTextTitle';
     wfProfileIn($fname);
     wfIncrStats('pcache_not_possible');
     $parserOutput = $wgParser->parse($text, $title, $this->parserOptions(), $linestart, true, $this->mRevisionId);
     $this->addParserOutput($parserOutput);
     wfProfileOut($fname);
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:10,代码来源:OutputPage.php


示例8: 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


示例9: getParserOutput

 /**
  * Lightweight method to get the parser output for a page, checking the parser cache
  * and so on. Doesn't consider most of the stuff that Article::view is forced to
  * consider, so it's not appropriate to use there.
  *
  * @since 1.16 (r52326) for LiquidThreads
  * 
  * @param $oldid mixed integer Revision ID or null
  */
 public function getParserOutput($oldid = null)
 {
     global $wgEnableParserCache, $wgUser;
     // Should the parser cache be used?
     $useParserCache = $wgEnableParserCache && $wgUser->getStubThreshold() == 0 && $this->exists() && $oldid === null;
     wfDebug(__METHOD__ . ': using parser cache: ' . ($useParserCache ? 'yes' : 'no') . "\n");
     if ($wgUser->getStubThreshold()) {
         wfIncrStats('pcache_miss_stub');
     }
     $parserOutput = false;
     if ($useParserCache) {
         $parserOutput = ParserCache::singleton()->get($this, $this->getParserOptions());
     }
     if ($parserOutput === false) {
         // Cache miss; parse and output it.
         $rev = Revision::newFromTitle($this->getTitle(), $oldid);
         return $this->getOutputFromWikitext($rev->getText(), $useParserCache);
     } else {
         return $parserOutput;
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:30,代码来源:Article.php


示例10: getDiffBody

 /**
  * Get the diff table body, without header
  *
  * @return mixed
  */
 function getDiffBody()
 {
     global $wgMemc;
     $fname = 'DifferenceEngine::getDiffBody';
     wfProfileIn($fname);
     // Cacheable?
     $key = false;
     if ($this->mOldid && $this->mNewid) {
         $key = wfMemcKey('diff', 'version', MW_DIFF_VERSION, 'oldid', $this->mOldid, 'newid', $this->mNewid);
         // Try cache
         if (!$this->mRefreshCache) {
             $difftext = $wgMemc->get($key);
             if ($difftext) {
                 wfIncrStats('diff_cache_hit');
                 $difftext = $this->localiseLineNumbers($difftext);
                 $difftext .= "\n<!-- diff cache key {$key} -->\n";
                 wfProfileOut($fname);
                 return $difftext;
             }
         }
         // don't try to load but save the result
     } else {
     }
     // Loadtext is permission safe, this just clears out the diff
     if (!$this->loadText()) {
         wfProfileOut($fname);
         return false;
     } else {
         if ($this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT)) {
             return '';
         } else {
             if ($this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT)) {
                 return '';
             }
         }
     }
     $difftext = $this->generateDiffBody($this->mOldtext, $this->mNewtext);
     // Save to cache for 7 days
     // Only do this for public revs, otherwise an admin can view the diff and a non-admin can nab it!
     if ($this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT)) {
         wfIncrStats('diff_uncacheable');
     } else {
         if ($this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT)) {
             wfIncrStats('diff_uncacheable');
         } else {
             if ($key !== false && $difftext !== false) {
                 wfIncrStats('diff_cache_miss');
                 $wgMemc->set($key, $difftext, 7 * 86400);
             } else {
                 wfIncrStats('diff_uncacheable');
             }
         }
     }
     // Replace line numbers with the text in the user's language
     if ($difftext !== false) {
         $difftext = $this->localiseLineNumbers($difftext);
     }
     wfProfileOut($fname);
     return $difftext;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:65,代码来源:DifferenceEngine.php


示例11: loadFromCache

 /**
  * Try to load video metadata from memcached.
  * @return Boolean: true on success.
  */
 private function loadFromCache()
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $this->dataLoaded = false;
     $key = $this->getCacheKey();
     $data = $wgMemc->get($key);
     if (!empty($data) && is_array($data)) {
         $this->url = $data['url'];
         $this->type = $data['type'];
         $this->submitter_user_id = $data['user_id'];
         $this->submitter_user_name = $data['user_name'];
         $this->create_date = $data['create_date'];
         $this->dataLoaded = true;
         $this->exists = true;
     }
     if ($this->dataLoaded) {
         wfDebug("Loaded Video:{$this->name} from cache\n");
         wfIncrStats('video_cache_hit');
     } else {
         wfIncrStats('video_cache_miss');
     }
     wfProfileOut(__METHOD__);
     return $this->dataLoaded;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:29,代码来源:VideoClass.php


示例12: get

 /**
  * Retrieve the ParserOutput from ParserCache.
  * false if not found or outdated.
  *
  * @param 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;
     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 (!$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;
     } 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;
     } else {
         wfIncrStats("pcache_hit");
     }
     wfProfileOut(__METHOD__);
     return $value;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:56,代码来源:ParserCache.php


示例13: 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


示例14: beforePageDisplayHTML


//.........这里部分代码省略.........
         }
     }
     if (self::$enableImages == 1) {
         $disableImages = $wgRequest->getCookie('disableImages');
         if ($disableImages) {
             $wgRequest->response()->setcookie('disableImages', '');
         }
         $location = str_replace('?enableImages=1', '', str_replace('&enableImages=1', '', $wgRequest->getFullRequestURL()));
         $location = str_replace('&mfi=1', '', str_replace('&mfi=0', '', $location));
         $location = $this->getRelativeURL($location);
         $wgRequest->response()->header('Location: ' . $location . '&mfi=1');
     }
     self::$format = $wgRequest->getText('format');
     self::$callback = $wgRequest->getText('callback');
     self::$requestedSegment = $wgRequest->getText('seg', 0);
     self::$search = $wgRequest->getText('search');
     self::$searchField = $wgRequest->getText('search', '');
     $device = new DeviceDetection();
     if ($xDevice) {
         $formatName = $xDevice;
     } else {
         $formatName = $device->formatName($userAgent, $acceptHeader);
     }
     self::$device = $device->format($formatName);
     if (self::$device['view_format'] === 'wml') {
         $this->contentFormat = 'WML';
     } elseif (self::$device['view_format'] === 'html') {
         $this->contentFormat = 'XHTML';
     }
     if (self::$useFormat === 'mobile-wap') {
         $this->contentFormat = 'WML';
     }
     if ($mobileAction == 'leave_feedback') {
         echo $this->renderLeaveFeedbackXHTML();
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'leave_feedback_post') {
         $this->getMsg();
         $subject = $wgRequest->getText('subject', '');
         $message = $wgRequest->getText('message', '');
         $token = $wgRequest->getText('edittoken', '');
         $title = Title::newFromText(self::$messages['mobile-frontend-feedback-page']);
         if ($title->userCan('edit') && !$wgUser->isBlockedFrom($title) && $wgUser->matchEditToken($token)) {
             $article = new Article($title, 0);
             $rawtext = $article->getRawText();
             $rawtext .= "\n== {$subject} == \n {$message} ~~~~ \n <small>User agent: {$userAgent}</small> ";
             $article->doEdit($rawtext, '');
         }
         $location = str_replace('&mobileaction=leave_feedback_post', '', $wgRequest->getFullRequestURL() . '&noticeid=1&useformat=mobile');
         $location = $this->getRelativeURL($location);
         $wgRequest->response()->header('Location: ' . $location);
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'disable_mobile_site' && $this->contentFormat == 'XHTML') {
         echo $this->renderDisableMobileSiteXHTML();
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'opt_in_mobile_site' && $this->contentFormat == 'XHTML') {
         echo $this->renderOptInMobileSiteXHTML();
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'opt_out_mobile_site' && $this->contentFormat == 'XHTML') {
         echo $this->renderOptOutMobileSiteXHTML();
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'opt_in_cookie') {
         wfIncrStats('mobile.opt_in_cookie_set');
         $this->setOptInOutCookie('1');
         $this->disableCaching();
         $location = wfExpandUrl(Title::newMainPage()->getFullURL(), PROTO_CURRENT);
         $wgRequest->response()->header('Location: ' . $location);
     }
     if ($mobileAction == 'opt_out_cookie') {
         $this->setOptInOutCookie('');
     }
     $this->getMsg();
     $this->disableCaching();
     $this->sendXDeviceVaryHeader();
     $this->sendApplicationVersionVaryHeader();
     $this->checkUserStatus();
     $this->checkUserLoggedIn();
     if (self::$title->isSpecial('Userlogin') && self::$isBetaGroupMember) {
         self::$wsLoginToken = $wgRequest->getSessionData('wsLoginToken');
         $q = array('action' => 'submitlogin', 'type' => 'login');
         $returnToVal = $wgRequest->getVal('returnto');
         if ($returnToVal) {
             $q['returnto'] = $returnToVal;
         }
         self::$wsLoginFormAction = self::$title->getLocalURL($q);
     }
     $this->setDefaultLogo();
     ob_start(array($this, 'DOMParse'));
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:MobileFrontend.php


示例15: getLagTimes

 /**
  * Get lag time for each DB
  * Results are cached for a short time in memcached
  */
 function getLagTimes()
 {
     wfProfileIn(__METHOD__);
     $expiry = 5;
     $requestRate = 10;
     global $wgMemc;
     $times = $wgMemc->get(wfMemcKey('lag_times'));
     if ($times) {
         # Randomly recache with probability rising over $expiry
         $elapsed = time() - $times['timestamp'];
         $chance = max(0, ($expiry - $elapsed) * $requestRate);
         if (mt_rand(0, $chance) != 0) {
             unset($times['timestamp']);
             wfProfileOut(__METHOD__);
             return $times;
         }
         wfIncrStats('lag_cache_miss_expired');
     } else {
         wfIncrStats('lag_cache_miss_absent');
     }
     # Cache key missing or expired
     $times = array();
     foreach ($this->mServers as $i => $conn) {
         if ($i == 0) {
             # Master
             $times[$i] = 0;
         } elseif ($this->openConnection($i)) {
             $times[$i] = $this->mConnections[$i]->getLag();
         }
     }
     # Add a timestamp key so we know when it was cached
     $times['timestamp'] = time();
     $wgMemc->set(wfMemcKey('lag_times'), $times, $expiry);
     # But don't give the timestamp to the caller
     unset($times['timestamp']);
     wfProfileOut(__METHOD__);
     return $times;
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:42,代码来源:LoadBalancer.php


示例16: getData

 /**
  * Get data of requested article.
  * @param Title $title
  * @param boolean $noImages
  * @return array
  */
 private function getData(Title $title, $noImages)
 {
     global $wgMemc, $wgUseTidy, $wgMFTidyMobileViewSections, $wgMFMinCachedPageSize, $wgMFSpecialCaseMainPage;
     $wp = $this->makeWikiPage($title);
     if ($this->followRedirects && $wp->isRedirect()) {
         $newTitle = $wp->getRedirectTarget();
         if ($newTitle) {
             $title = $newTitle;
             $this->getResult()->addValue(null, $this->getModuleName(), array('redirected' => $title->getPrefixedText()));
             if ($title->getNamespace() < 0) {
                 $this->getResult()->addValue(null, $this->getModuleName(), array('viewable' => 'no'));
                 return array();
             }
             $wp = $this->makeWikiPage($title);
         }
     }
     $latest = $wp->getLatest();
     if ($this->file) {
         $key = wfMemcKey('mf', 'mobileview', self::CACHE_VERSION, $noImages, $latest, $this->noTransform, $this->file->getSha1(), $this->variant);
         $cacheExpiry = 3600;
     } else {
         if (!$latest) {
             // https://bugzilla.wikimedia.org/show_bug.cgi?id=53378
             // Title::exists() above doesn't seem to always catch recently deleted pages
             $this->dieUsageMsg(array('notanarticle', $title->getPrefixedText()));
         }
         $parserOptions = $this->makeParserOptions($wp);
         $parserCacheKey = ParserCache::singleton()->getKey($wp, $parserOptions);
         $key = wfMemcKey('mf', 'mobileview', self::CACHE_VERSION, $noImages, $latest, $this->noTransform, $parserCacheKey);
     }
     $data = $wgMemc->get($key);
     if ($data) {
         wfIncrStats('mobile.view.cache-hit');
         return $data;
     }
     wfIncrStats('mobile.view.cache-miss');
     if ($this->file) {
         $html = $this->getFilePage($title);
     } else {
         $parserOutput = $this->getParserOutput($wp, $parserOptions);
         $html = $parserOutput->getText();
         $cacheExpiry = $parserOutput->getCacheExpiry();
     }
     if (!$this->noTransform) {
         $mf = new MobileFormatter(MobileFormatter::wrapHTML($html), $title);
         $mf->setRemoveMedia($noImages);
         $mf->filterContent();
         $mf->setIsMainPage($this->mainPage && $wgMFSpecialCaseMainPage);
         $html = $mf->getText();
     }
     if ($this->mainPage || $this->file) {
         $data = array('sections' => array(), 'text' => array($html), 'refsections' => array());
     } else {
         $data = array();
         $data['sections'] = $parserOutput->getSections();
         $sectionCount = count($data['sections']);
         for ($i = 0; $i < $sectionCount; $i++) {
             $data['sections'][$i]['line'] = $title->getPageLanguage()->convert($data['sections'][$i]['line']);
         }
         $chunks = preg_split('/<h(?=[1-6]\\b)/i', $html);
         if (count($chunks) != count($data['sections']) + 1) {
             wfDebugLog('mobile', __METHOD__ . "(): mismatching number of " . "sections from parser and split on page {$title->getPrefixedText()}, oldid={$latest}");
             // We can't be sure about anything here, return all page HTML as one big section
             $chunks = array($html);
             $data['sections'] = array();
         }
         $data['text'] = array();
         $data['refsections'] = array();
         foreach ($chunks as $chunk) {
             if (count($data['text'])) {
                 $chunk = "<h{$chunk}";
             }
             if ($wgUseTidy && $wgMFTidyMobileViewSections && count($chunks) > 1) {
                 $chunk = MWTidy::tidy($chunk);
             }
             if (preg_match('/<ol\\b[^>]*?class="references"/', $chunk)) {
                 $data['refsections'][count($data['text'])] = true;
             }
             $data['text'][] = $chunk;
         }
         if ($this->usePageImages) {
             $image = $this->getPageImage($title);
             if ($image) {
                 $data['image'] = $image->getTitle()->getText();
             }
         }
     }
     $data['lastmodified'] = wfTimestamp(TS_ISO_8601, $wp->getTimestamp());
     // Page id
     $data['id'] = $wp->getId();
     $user = User::newFromId($wp->getUser());
     if (!$user->isAnon()) {
         $data['lastmodifiedby'] = array('name' => $wp->getUserText(), 'gender' => $user->getOption('gender'));
     } else {
//.........这里部分代码省略.........
开发者ID:negati-ve,项目名称:openshift-mediawiki,代码行数:101,代码来源:ApiMobileView.php


示例17: incrStats

 /**
  * Call wfIncrStats() for the queue overall and for the queue type
  *
  * @param string $key Event type
  * @param string $type Job type
  * @param int $delta
  * @param string $wiki Wiki ID (added in 1.23)
  * @since 1.22
  */
 public static function incrStats($key, $type, $delta = 1, $wiki = null)
 {
     wfIncrStats($key, $delta);
     wfIncrStats("{$key}-{$type}", $delta);
     if ($wiki !== null) {
         wfIncrStats("{$key}-{$type}-{$wiki}", $delta);
     }
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:17,代码来源:JobQueue.php


示例18: view

 /**
  * This is the default action of the script: just view the page of
  * the given title.
  */
 function view()
 {
     global $wgUser, $wgOut, $wgRequest, $wgContLang;
     global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser;
     global $wgUseTrackbacks, $wgNamespaceRobotPolicies;
     $sk = $wgUser->getSkin();
     wfProfileIn(__METHOD__);
     $parserCache =& ParserCache::singleton();
     $ns = $this->mTitle->getNamespace();
     # shortcut
     # Get variables from query string
     $oldid = $this->getOldID();
     # getOldID may want us to redirect somewhere else
     if ($this->mRedirectUrl) {
         $wgOut->redirect($this->mRedirectUrl);
         wfProfileOut(__METHOD__);
         return;
     }
     $diff = $wgRequest->getVal('diff');
     $rcid = $wgRequest->getVal('rcid');
     $rdfrom = $wgRequest->getVal('rdfrom');
     $wgOut->setArticleFlag(true);
     if (isset($wgNamespaceRobotPolicies[$ns])) {
         $policy = $wgNamespaceRobotPolicies[$ns];
     } else {
         # The default policy. Dev note: make sure you change the documentation
         # in DefaultSettings.php before changing it.
         $policy = 'index,follow';
     }
     $wgOut->setRobotpolicy($policy);
     # If we got diff and oldid in the query, we want to see a
     # diff page instead of the article.
     if (!is_null($diff)) {
         $wgOut->setPageTitle($this->mTitle->getPrefixedText());
         $de = new DifferenceEngine($this->mTitle, $oldid, $diff, $rcid);
         // DifferenceEngine directly fetched the revision:
         $this->mRevIdFetched = $de->mNewid;
         $de->showDiffPage();
         // Needed to get the page's current revision
         $this->loadPageData();
         if ($diff == 0 || $diff == $this->mLatest) {
             # Run view updates for current revision only
             $this->viewUpdates();
         }
         wfProfileOut(__METHOD__);
         return;
     }
     if (empty($oldid) && $this->checkTouched()) {
         $wgOut->setETag($parserCache->getETag($this, $wgUser));
         if ($wgOut->checkLastModified($this->mTouched)) {
             wfProfileOut(__METHOD__);
             return;
         } else {
             if ($this->tryFileCache()) {
                 # tell wgOut that output is taken care of
                 $wgOut->disable();
                 $this->viewUpdates();
                 wfProfileOut(__METHOD__);
                 return;
             }
         }
     }
     # Should the parser cache be used?
     $pcache = $wgEnableParserCache && intval($wgUser->getOption('stubthreshold')) == 0 && $this->exists() && empty($oldid);
     wfDebug('Article::view using parser cache: ' . ($pcache ? 'yes' : 'no') . "\n");
     if ($wgUser->getOption('stubthreshold')) {
         wfIncrStats('pcache_miss_stub');
     }
     $wasRedirected = false;
     if (isset($this->mRedirectedFrom)) {
         // This is an internally redirected page view.
         // We'll need a backlink to the source page for navigation.
         if (wfRunHooks('ArticleViewRedirect', array(&$this))) {
             $sk = $wgUser->getSkin();
             $redir = $sk->makeKnownLinkObj($this->mRedirectedFrom, '', 'redirect=no');
             $s = wfMsg('redirectedfrom', $redir);
             $wgOut->setSubtitle($s);
             // Set the fragment if one was specified in the redirect
             if (strval($this->mTitle->getFragment()) != '') {
                 $fragment = Xml::escapeJsString($this->mTitle->getFragmentForURL());
                 $wgOut->addInlineScript("redirectToFragment(\"{$fragment}\");");
             }
             $wasRedirected = true;
         }
     } elseif (!empty($rdfrom)) {
         // This is an externally redirected view, from some other wiki.
         // If it was reported from a trusted site, supply a backlink.
         global $wgRedirectSources;
         if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) {
             $sk = $wgUser->getSkin();
             $redir = $sk->makeExternalLink($rdfrom, $rdfrom);
             $s = wfMsg('redirectedfrom', $redir);
             $wgOut->setSubtitle($s);
             $wasRedirected = true;
         }
     }
//.........这里部分代码省略.........
开发者ID:negabaro,项目名称:alfresco,代码行数:101,代码来源:Article.php


示例19: 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:
       

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfIniGetBool函数代码示例发布时间:2022-05-23
下一篇:
PHP wfHttpError函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap