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


PHP Title::getLatestRevID方法代码示例

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


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

示例1: invalidateTitle

 protected function invalidateTitle(\Title $title)
 {
     global $wgParsoidCacheServers, $wgContentNamespaces;
     if (!in_array($title->getNamespace(), $wgContentNamespaces)) {
         return false;
     }
     # First request the new version
     $parsoidInfo = array();
     $parsoidInfo['cacheID'] = $title->getPreviousRevisionID($title->getLatestRevID());
     $parsoidInfo['changedTitle'] = $this->title->getPrefixedDBkey();
     $requests = array();
     foreach ($wgParsoidCacheServers as $server) {
         $singleUrl = $this->getParsoidURL($title);
         $requests[] = array('url' => $singleUrl, 'headers' => array('X-Parsoid: ' . json_encode($parsoidInfo), 'Cache-control: no-cache'));
         $this->wikiaLog(array("action" => "invalidateTitle", "get_url" => $singleUrl));
     }
     $this->checkCurlResults(\CurlMultiClient::request($requests));
     # And now purge the previous revision so that we make efficient use of
     # the Varnish cache space without relying on LRU. Since the URL
     # differs we can't use implicit refresh.
     $requests = array();
     foreach ($wgParsoidCacheServers as $server) {
         // @TODO: this triggers a getPreviousRevisionID() query per server
         $singleUrl = $this->getParsoidURL($title, true);
         $requests[] = array('url' => $singleUrl);
         $this->wikiaLog(array("action" => "invalidateTitle", "purge_url" => $singleUrl));
     }
     $options = \CurlMultiClient::getDefaultOptions();
     $options[CURLOPT_CUSTOMREQUEST] = "PURGE";
     return $this->checkCurlResults(\CurlMultiClient::request($requests, $options));
 }
开发者ID:yusufchang,项目名称:app,代码行数:31,代码来源:ParsoidCacheUpdateTask.class.php

示例2: getRevId

 function getRevId()
 {
     if ($this->mId) {
         return $this->mId;
     } else {
         return $this->mTitle->getLatestRevID();
     }
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:8,代码来源:SpecialCite_body.php

示例3: doUpdates

 /**
  * Driver function that handles updating assessment data in database
  * @param Title $titleObj Title object of the subject page
  * @param array $assessmentData Data for all assessments compiled
  */
 public static function doUpdates($titleObj, $assessmentData)
 {
     global $wgUpdateRowsPerQuery;
     $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
     $ticket = $factory->getEmptyTransactionTicket(__METHOD__);
     $pageId = $titleObj->getArticleID();
     $revisionId = $titleObj->getLatestRevID();
     // Compile a list of projects to find out which ones to be deleted afterwards
     $projects = array();
     foreach ($assessmentData as $parserData) {
         // For each project, get the corresponding ID from page_assessments_projects table
         $projectId = self::getProjectId($parserData[0]);
         if ($projectId === false) {
             $projectId = self::insertProject($parserData[0]);
         }
         $projects[$parserData[0]] = $projectId;
     }
     $projectsInDb = self::getAllProjects($pageId, self::READ_LATEST);
     $toInsert = array_diff($projects, $projectsInDb);
     $toDelete = array_diff($projectsInDb, $projects);
     $toUpdate = array_intersect($projects, $projectsInDb);
     $i = 0;
     // Add and update records to the database
     foreach ($assessmentData as $parserData) {
         $projectId = $projects[$parserData[0]];
         if ($projectId) {
             $class = $parserData[1];
             $importance = $parserData[2];
             $values = array('pa_page_id' => $pageId, 'pa_project_id' => $projectId, 'pa_class' => $class, 'pa_importance' => $importance, 'pa_page_revision' => $revisionId);
             if (in_array($projectId, $toInsert)) {
                 self::insertRecord($values);
             } elseif (in_array($projectId, $toUpdate)) {
                 self::updateRecord($values);
             }
             // Check for database lag if there's a huge number of assessments
             if ($i > 0 && $i % $wgUpdateRowsPerQuery == 0) {
                 $factory->commitAndWaitForReplication(__METHOD__, $ticket);
             }
             $i++;
         }
     }
     // Delete records from the database
     foreach ($toDelete as $project) {
         $values = array('pa_page_id' => $pageId, 'pa_project_id' => $project);
         self::deleteRecord($values);
         // Check for database lag if there's a huge number of deleted assessments
         if ($i > 0 && $i % $wgUpdateRowsPerQuery == 0) {
             $factory->commitAndWaitForReplication(__METHOD__, $ticket);
         }
         $i++;
     }
     return;
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-PageAssessments,代码行数:58,代码来源:PageAssessmentsBody.php

示例4: doSaveComment

 /**
  * doSaveComment -- save comment
  *
  * @access public
  *
  * @param string $text
  * @param User $user
  * @param Title $title
  * @param int $commentId
  * @param bool $force
  * @param string $summary
  * @param bool $preserveMetadata : hack to fix bug 102384 (prevent metadata override when trying to modify one of metadata keys)
  *
  * @return Array|false TODO: Document what the array contains.
  */
 public function doSaveComment($text, $user, $title = null, $commentId = 0, $force = false, $summary = '', $preserveMetadata = false)
 {
     global $wgTitle;
     wfProfileIn(__METHOD__);
     $metadata = $this->mMetadata;
     $this->load(true);
     if ($force || $this->canEdit()) {
         if (wfReadOnly()) {
             wfProfileOut(__METHOD__);
             return false;
         }
         if (!$text || !strlen($text)) {
             wfProfileOut(__METHOD__);
             return false;
         }
         if (empty($this->mTitle) && !$commentId) {
             wfProfileOut(__METHOD__);
             return false;
         }
         $commentTitle = $this->mTitle ? $this->mTitle : Title::newFromId($commentId);
         /**
          * because we save different title via Ajax request
          */
         $origTitle = $wgTitle;
         $wgTitle = $commentTitle;
         /**
          * add article using EditPage class (for hooks)
          */
         $article = new Article($commentTitle, intval($this->mLastRevId));
         if ($preserveMetadata) {
             $this->mMetadata = $metadata;
         }
         $retval = self::doSaveAsArticle($text, $article, $user, $this->mMetadata, $summary);
         if (!empty($title)) {
             $purgeTarget = $title;
         } else {
             $purgeTarget = $origTitle;
         }
         ArticleCommentList::purgeCache($purgeTarget);
         $res = [$retval, $article];
     } else {
         $res = false;
     }
     $this->mLastRevId = $this->mTitle->getLatestRevID(Title::GAID_FOR_UPDATE);
     $this->mLastRevision = Revision::newFromId($this->mLastRevId);
     wfProfileOut(__METHOD__);
     return $res;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:63,代码来源:ArticleComment.class.php

示例5: getUserNameFromRevision

 public static function getUserNameFromRevision(Title $title)
 {
     $rev = Revision::newFromId($title->getLatestRevID());
     if (!empty($rev)) {
         $user = User::newFromId($rev->getUser());
         if (!empty($user)) {
             $userName = $user->getName();
         } else {
             $userName = self::getCommentByAnonMsg();
         }
     }
     return $userName;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:ArticleCommentInit.class.php

示例6: statelessFetchRevision

 /**
  * Wrapper around Revision::newFromTitle to allow passing additional parameters
  * without passing them on to it.
  *
  * @since 1.24
  * @param Title $title
  * @param Parser|bool $parser
  * @return Revision|bool False if missing
  */
 public static function statelessFetchRevision(Title $title, $parser = false)
 {
     $pageId = $title->getArticleID();
     $revId = $title->getLatestRevID();
     $rev = Revision::newKnownCurrent(wfGetDB(DB_REPLICA), $pageId, $revId);
     if ($rev) {
         $rev->setTitle($title);
     }
     return $rev;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:19,代码来源:Parser.php


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