*/
use MediaWiki\MediaWikiServices;
-use MediaWiki\Permissions\PermissionManager;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\Storage\NameTableAccessException;
*/
protected $isSlotDiffRenderer = false;
- /**#@-*/
+ /** #@- */
/**
* @param IContextSource|null $context Context to use, anything else will be ignored
* @return string|bool Link HTML or false
*/
public function deletedLink( $id ) {
- if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+ if ( $permissionManager->userHasRight( $this->getUser(), 'deletedhistory' ) ) {
$dbr = wfGetDB( DB_REPLICA );
$arQuery = Revision::getArchiveQueryInfo();
$row = $dbr->selectRow(
$permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
- if ( $samePage && $this->mNewPage && $permissionManager->userCan(
- 'edit', $user, $this->mNewPage, PermissionManager::RIGOR_QUICK
+ if ( $samePage && $this->mNewPage && $permissionManager->quickUserCan(
+ 'edit', $user, $this->mNewPage
) ) {
if ( $this->mNewRev->isCurrent() && $permissionManager->userCan(
'rollback', $user, $this->mNewPage
}
}
- if ( !$this->mOldRev->isDeleted( RevisionRecord::DELETED_TEXT ) &&
- !$this->mNewRev->isDeleted( RevisionRecord::DELETED_TEXT )
+ if ( $this->userCanEdit( $this->mOldRev ) &&
+ $this->userCanEdit( $this->mNewRev )
) {
$undoLink = Html::element( 'a', [
'href' => $this->mNewPage->getLocalURL( [
protected function getMarkPatrolledLinkInfo() {
$user = $this->getUser();
$config = $this->getConfig();
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
// Prepare a change patrol link, if applicable
if (
// Is patrolling enabled and the user allowed to?
$config->get( 'UseRCPatrol' ) &&
- $this->mNewPage && $this->mNewPage->quickUserCan( 'patrol', $user ) &&
+ $this->mNewPage &&
+ $permissionManager->quickUserCan( 'patrol', $user, $this->mNewPage ) &&
// Only do this if the revision isn't more than 6 hours older
// than the Max RC age (6h because the RC might not be cleaned out regularly)
RecentChange::isInRCLifespan( $this->mNewRev->getTimestamp(), 21600 )
// Build the link
if ( $rcid ) {
$this->getOutput()->preventClickjacking();
- if ( $user->isAllowed( 'writeapi' ) ) {
+ if ( $permissionManager->userHasRight( $user, 'writeapi' ) ) {
$this->getOutput()->addModules( 'mediawiki.page.patrol.ajax' );
}
) {
$out->addParserOutput( $parserOutput, [
'enableSectionEditLinks' => $this->mNewRev->isCurrent()
- && $this->mNewRev->getTitle()->quickUserCan( 'edit', $this->getUser() ),
+ && MediaWikiServices::getInstance()->getPermissionManager()->quickUserCan(
+ 'edit',
+ $this->getUser(),
+ $this->mNewRev->getTitle()
+ )
] );
}
}
return wfMessage( $msg )->numParams( $numEdits, $numUsers )->parse();
}
+ /**
+ * @param Revision $rev
+ * @return bool whether the user can see and edit the revision.
+ */
+ private function userCanEdit( Revision $rev ) {
+ $user = $this->getUser();
+
+ if ( !$rev->getContentHandler()->supportsDirectEditing() ) {
+ return false;
+ }
+
+ if ( !$rev->userCan( RevisionRecord::DELETED_TEXT, $user ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Get a header for a specified revision.
*
$header = Linker::linkKnown( $title, $header, [],
[ 'oldid' => $rev->getId() ] );
- if ( $rev->userCan( RevisionRecord::DELETED_TEXT, $user ) ) {
+ if ( $this->userCanEdit( $rev ) ) {
$editQuery = [ 'action' => 'edit' ];
if ( !$rev->isCurrent() ) {
$editQuery['oldid'] = $rev->getId();
}
- $key = $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold';
+ $key = MediaWikiServices::getInstance()->getPermissionManager()
+ ->quickUserCan( 'edit', $user, $title ) ? 'editold' : 'viewsourceold';
$msg = $this->msg( $key )->escaped();
$editLink = $this->msg( 'parentheses' )->rawParams(
Linker::linkKnown( $title, $msg, [], $editQuery ) )->escaped();