本文整理汇总了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));
}
示例2: getRevId
function getRevId()
{
if ($this->mId) {
return $this->mId;
} else {
return $this->mTitle->getLatestRevID();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}