本文整理汇总了PHP中ManualLogEntry::setAssociatedRevId方法的典型用法代码示例。如果您正苦于以下问题:PHP ManualLogEntry::setAssociatedRevId方法的具体用法?PHP ManualLogEntry::setAssociatedRevId怎么用?PHP ManualLogEntry::setAssociatedRevId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualLogEntry
的用法示例。
在下文中一共展示了ManualLogEntry::setAssociatedRevId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doUpdateRestrictions
//.........这里部分代码省略.........
$logAction = 'unprotect';
} elseif ($isProtected) {
$revCommentMsg = 'modifiedarticleprotection';
$logAction = 'modify';
} else {
$revCommentMsg = 'protectedarticle';
$logAction = 'protect';
}
// Truncate for whole multibyte characters
$reason = $wgContLang->truncate($reason, 255);
$logRelationsValues = [];
$logRelationsField = null;
$logParamsDetails = [];
// Null revision (used for change tag insertion)
$nullRevision = null;
if ($id) {
// Protection of existing page
if (!Hooks::run('ArticleProtect', [&$this, &$user, $limit, $reason])) {
return Status::newGood();
}
// Only certain restrictions can cascade...
$editrestriction = isset($limit['edit']) ? [$limit['edit']] : $this->mTitle->getRestrictions('edit');
foreach (array_keys($editrestriction, 'sysop') as $key) {
$editrestriction[$key] = 'editprotected';
// backwards compatibility
}
foreach (array_keys($editrestriction, 'autoconfirmed') as $key) {
$editrestriction[$key] = 'editsemiprotected';
// backwards compatibility
}
$cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
foreach (array_keys($cascadingRestrictionLevels, 'sysop') as $key) {
$cascadingRestrictionLevels[$key] = 'editprotected';
// backwards compatibility
}
foreach (array_keys($cascadingRestrictionLevels, 'autoconfirmed') as $key) {
$cascadingRestrictionLevels[$key] = 'editsemiprotected';
// backwards compatibility
}
// The schema allows multiple restrictions
if (!array_intersect($editrestriction, $cascadingRestrictionLevels)) {
$cascade = false;
}
// insert null revision to identify the page protection change as edit summary
$latest = $this->getLatest();
$nullRevision = $this->insertProtectNullRevision($revCommentMsg, $limit, $expiry, $cascade, $reason, $user);
if ($nullRevision === null) {
return Status::newFatal('no-null-revision', $this->mTitle->getPrefixedText());
}
$logRelationsField = 'pr_id';
// Update restrictions table
foreach ($limit as $action => $restrictions) {
$dbw->delete('page_restrictions', ['pr_page' => $id, 'pr_type' => $action], __METHOD__);
if ($restrictions != '') {
$cascadeValue = $cascade && $action == 'edit' ? 1 : 0;
$dbw->insert('page_restrictions', ['pr_id' => $dbw->nextSequenceValue('page_restrictions_pr_id_seq'), 'pr_page' => $id, 'pr_type' => $action, 'pr_level' => $restrictions, 'pr_cascade' => $cascadeValue, 'pr_expiry' => $dbw->encodeExpiry($expiry[$action])], __METHOD__);
$logRelationsValues[] = $dbw->insertId();
$logParamsDetails[] = ['type' => $action, 'level' => $restrictions, 'expiry' => $expiry[$action], 'cascade' => (bool) $cascadeValue];
}
}
// Clear out legacy restriction fields
$dbw->update('page', ['page_restrictions' => ''], ['page_id' => $id], __METHOD__);
Hooks::run('NewRevisionFromEditComplete', [$this, $nullRevision, $latest, $user]);
Hooks::run('ArticleProtectComplete', [&$this, &$user, $limit, $reason]);
} else {
// Protection of non-existing page (also known as "title protection")
// Cascade protection is meaningless in this case
$cascade = false;
if ($limit['create'] != '') {
$dbw->replace('protected_titles', [['pt_namespace', 'pt_title']], ['pt_namespace' => $this->mTitle->getNamespace(), 'pt_title' => $this->mTitle->getDBkey(), 'pt_create_perm' => $limit['create'], 'pt_timestamp' => $dbw->timestamp(), 'pt_expiry' => $dbw->encodeExpiry($expiry['create']), 'pt_user' => $user->getId(), 'pt_reason' => $reason], __METHOD__);
$logParamsDetails[] = ['type' => 'create', 'level' => $limit['create'], 'expiry' => $expiry['create']];
} else {
$dbw->delete('protected_titles', ['pt_namespace' => $this->mTitle->getNamespace(), 'pt_title' => $this->mTitle->getDBkey()], __METHOD__);
}
}
$this->mTitle->flushRestrictions();
InfoAction::invalidateCache($this->mTitle);
if ($logAction == 'unprotect') {
$params = [];
} else {
$protectDescriptionLog = $this->protectDescriptionLog($limit, $expiry);
$params = ['4::description' => $protectDescriptionLog, '5:bool:cascade' => $cascade, 'details' => $logParamsDetails];
}
// Update the protection log
$logEntry = new ManualLogEntry('protect', $logAction);
$logEntry->setTarget($this->mTitle);
$logEntry->setComment($reason);
$logEntry->setPerformer($user);
$logEntry->setParameters($params);
if (!is_null($nullRevision)) {
$logEntry->setAssociatedRevId($nullRevision->getId());
}
$logEntry->setTags($tags);
if ($logRelationsField !== null && count($logRelationsValues)) {
$logEntry->setRelations([$logRelationsField => $logRelationsValues]);
}
$logId = $logEntry->insert();
$logEntry->publish($logId);
return Status::newGood($logId);
}