*/
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(
# Check if one of the revisions is deleted/suppressed
$deleted = $suppressed = false;
- $allowed = $this->mNewRev->userCan( Revision::DELETED_TEXT, $user );
+ $allowed = $this->mNewRev->userCan( RevisionRecord::DELETED_TEXT, $user );
$revisionTools = [];
if ( $this->mNewRev->isCurrent() && $permissionManager->userCan(
'rollback', $user, $this->mNewPage
) ) {
- $rollbackLink = Linker::generateRollback( $this->mNewRev, $this->getContext() );
+ $rollbackLink = Linker::generateRollback( $this->mNewRev, $this->getContext(),
+ [ 'noBrackets' ] );
if ( $rollbackLink ) {
$out->preventClickjacking();
$rollback = "\u{00A0}\u{00A0}\u{00A0}" . $rollbackLink;
}
}
- if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) &&
- !$this->mNewRev->isDeleted( Revision::DELETED_TEXT )
+ if ( $this->userCanEdit( $this->mOldRev ) &&
+ $this->userCanEdit( $this->mNewRev )
) {
$undoLink = Html::element( 'a', [
'href' => $this->mNewPage->getLocalURL( [
Hooks::run( 'DifferenceEngineOldHeader', [ $this, &$oldHeader, $prevlink, $oldminor,
$diffOnly, $ldel, $this->unhide ] );
- if ( $this->mOldRev->isDeleted( Revision::DELETED_TEXT ) ) {
+ if ( $this->mOldRev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
$deleted = true; // old revisions text is hidden
- if ( $this->mOldRev->isDeleted( Revision::DELETED_RESTRICTED ) ) {
+ if ( $this->mOldRev->isDeleted( RevisionRecord::DELETED_RESTRICTED ) ) {
$suppressed = true; // also suppressed
}
}
# Check if this user can see the revisions
- if ( !$this->mOldRev->userCan( Revision::DELETED_TEXT, $user ) ) {
+ if ( !$this->mOldRev->userCan( RevisionRecord::DELETED_TEXT, $user ) ) {
$allowed = false;
}
}
Hooks::run( 'DifferenceEngineNewHeader', [ $this, &$newHeader, $formattedRevisionTools,
$nextlink, $rollback, $newminor, $diffOnly, $rdel, $this->unhide ] );
- if ( $this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
+ if ( $this->mNewRev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
$deleted = true; // new revisions text is hidden
- if ( $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED ) ) {
+ if ( $this->mNewRev->isDeleted( RevisionRecord::DELETED_RESTRICTED ) ) {
$suppressed = true; // also suppressed
}
}
// Build the link
if ( $rcid ) {
$this->getOutput()->preventClickjacking();
- if ( $user->isAllowed( 'writeapi' ) ) {
+ if ( MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'writeapi' ) ) {
$this->getOutput()->addModules( 'mediawiki.page.patrol.ajax' );
}
if ( !$this->loadRevisionData() ) {
return false;
} elseif ( $this->mOldRev &&
- !$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
+ !$this->mOldRev->userCan( RevisionRecord::DELETED_TEXT, $this->getUser() )
) {
return false;
} elseif ( $this->mNewRev &&
- !$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
+ !$this->mNewRev->userCan( RevisionRecord::DELETED_TEXT, $this->getUser() )
) {
return false;
}
$users = $this->mNewPage->getAuthorsBetween( $oldRev, $newRev, $limit );
$numUsers = count( $users );
- if ( $numUsers == 1 && $users[0] == $newRev->getUserText( Revision::RAW ) ) {
+ if ( $numUsers == 1 && $users[0] == $newRev->getUserText( RevisionRecord::RAW ) ) {
$numUsers = 0; // special case to say "by the same user" instead of "by one other user"
}
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( Revision::DELETED_TEXT, $user ) ) {
+ if ( $this->userCanEdit( $rev ) ) {
$editQuery = [ 'action' => 'edit' ];
if ( !$rev->isCurrent() ) {
$editQuery['oldid'] = $rev->getId();
[ 'class' => 'mw-diff-edit' ],
$editLink
);
- if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
+ if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
$header = Html::rawElement(
'span',
[ 'class' => 'history-deleted' ],
}
if ( $this->mOldRev ) {
- $this->mOldContent = $this->mOldRev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
+ $this->mOldContent = $this->mOldRev->getContent(
+ RevisionRecord::FOR_THIS_USER, $this->getUser()
+ );
if ( $this->mOldContent === null ) {
return false;
}
}
- $this->mNewContent = $this->mNewRev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
+ $this->mNewContent = $this->mNewRev->getContent(
+ RevisionRecord::FOR_THIS_USER, $this->getUser()
+ );
Hooks::run( 'DifferenceEngineLoadTextAfterNewContentIsLoaded', [ $this ] );
if ( $this->mNewContent === null ) {
return false;
return false;
}
- $this->mNewContent = $this->mNewRev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
+ $this->mNewContent = $this->mNewRev->getContent(
+ RevisionRecord::FOR_THIS_USER, $this->getUser()
+ );
Hooks::run( 'DifferenceEngineAfterLoadNewText', [ $this ] );