r99633 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99632‎ | r99633 | r99634 >
Date:15:09, 12 October 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Added User paremeter to Revision::userCan(), Revision::userCanBitfield(), LogEventsList::userCan(), LogEventsList::userCanBitfield(), File::userCan() and its subclasses so that they can check against any user instead of always $wgUser.
* Updated callers that have a context or may use another user than $wgUser
* Revision::getUser(), Revision::getUserText(), Revision::getComment() and Revision::getText() also have a User as parameter, but it will be used only when Revision::FOR_THIS_USER is passed in the first parameter
Modified paths:
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/Revision.php (modified) (history)
  • /trunk/phase3/includes/RevisionList.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ArchivedFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/includes/filerepo/OldLocalFile.php (modified) (history)
  • /trunk/phase3/includes/revisiondelete/RevisionDelete.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialDeletedContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMergeHistory.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/OldLocalFile.php
@@ -205,11 +205,12 @@
206206 * field of this image file, if it's marked as deleted.
207207 *
208208 * @param $field Integer
 209+ * @param $user User object to check, or null to use $wgUser
209210 * @return bool
210211 */
211 - function userCan( $field ) {
 212+ function userCan( $field, User $user = null ) {
212213 $this->load();
213 - return Revision::userCanBitfield( $this->deleted, $field );
 214+ return Revision::userCanBitfield( $this->deleted, $field, $user );
214215 }
215216
216217 /**
Index: trunk/phase3/includes/filerepo/File.php
@@ -1437,9 +1437,10 @@
14381438 * field of this file, if it's marked as deleted.
14391439 * STUB
14401440 * @param $field Integer
 1441+ * @param $user User object to check, or null to use $wgUser
14411442 * @return Boolean
14421443 */
1443 - function userCan( $field ) {
 1444+ function userCan( $field, User $user = null ) {
14441445 return true;
14451446 }
14461447
Index: trunk/phase3/includes/filerepo/ArchivedFile.php
@@ -461,10 +461,11 @@
462462 * Determine if the current user is allowed to view a particular
463463 * field of this FileStore image file, if it's marked as deleted.
464464 * @param $field Integer
 465+ * @param $user User object to check, or null to use $wgUser
465466 * @return bool
466467 */
467 - public function userCan( $field ) {
 468+ public function userCan( $field, User $user = null ) {
468469 $this->load();
469 - return Revision::userCanBitfield( $this->deleted, $field );
 470+ return Revision::userCanBitfield( $this->deleted, $field, $user );
470471 }
471472 }
Index: trunk/phase3/includes/revisiondelete/RevisionDelete.php
@@ -132,11 +132,11 @@
133133 }
134134
135135 public function canView() {
136 - return $this->revision->userCan( Revision::DELETED_RESTRICTED );
 136+ return $this->revision->userCan( Revision::DELETED_RESTRICTED, $this->list->getUser() );
137137 }
138138
139139 public function canViewContent() {
140 - return $this->revision->userCan( Revision::DELETED_TEXT );
 140+ return $this->revision->userCan( Revision::DELETED_TEXT, $this->list->getUser() );
141141 }
142142
143143 public function getBits() {
@@ -509,11 +509,11 @@
510510 }
511511
512512 public function canView() {
513 - return $this->file->userCan( File::DELETED_RESTRICTED );
 513+ return $this->file->userCan( File::DELETED_RESTRICTED, $this->list->getUser() );
514514 }
515515
516516 public function canViewContent() {
517 - return $this->file->userCan( File::DELETED_FILE );
 517+ return $this->file->userCan( File::DELETED_FILE, $this->list->getUser() );
518518 }
519519
520520 public function getBits() {
@@ -596,7 +596,7 @@
597597 * @return string HTML
598598 */
599599 protected function getUserTools() {
600 - if( $this->file->userCan( Revision::DELETED_USER ) ) {
 600+ if( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) {
601601 $link = Linker::userLink( $this->file->user, $this->file->user_text ) .
602602 Linker::userToolLinks( $this->file->user, $this->file->user_text );
603603 } else {
@@ -615,7 +615,7 @@
616616 * @return string HTML
617617 */
618618 protected function getComment() {
619 - if( $this->file->userCan( File::DELETED_COMMENT ) ) {
 619+ if( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) {
620620 $block = Linker::commentBlock( $this->file->description );
621621 } else {
622622 $block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
@@ -807,7 +807,7 @@
808808 }
809809
810810 public function canView() {
811 - return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED );
 811+ return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() );
812812 }
813813
814814 public function canViewContent() {
Index: trunk/phase3/includes/LogEventsList.php
@@ -557,10 +557,11 @@
558558 *
559559 * @param $row Row
560560 * @param $field Integer
 561+ * @param $user User object to check, or null to use $wgUser
561562 * @return Boolean
562563 */
563 - public static function userCan( $row, $field ) {
564 - return self::userCanBitfield( $row->log_deleted, $field );
 564+ public static function userCan( $row, $field, User $user = null ) {
 565+ return self::userCanBitfield( $row->log_deleted, $field, $user );
565566 }
566567
567568 /**
@@ -569,19 +570,22 @@
570571 *
571572 * @param $bitfield Integer (current field)
572573 * @param $field Integer
 574+ * @param $user User object to check, or null to use $wgUser
573575 * @return Boolean
574576 */
575 - public static function userCanBitfield( $bitfield, $field ) {
 577+ public static function userCanBitfield( $bitfield, $field, User $user = null ) {
576578 if( $bitfield & $field ) {
577 - global $wgUser;
578 -
579579 if ( $bitfield & LogPage::DELETED_RESTRICTED ) {
580580 $permission = 'suppressrevision';
581581 } else {
582582 $permission = 'deletedhistory';
583583 }
584584 wfDebug( "Checking for $permission due to $field match on $bitfield\n" );
585 - return $wgUser->isAllowed( $permission );
 585+ if ( $user === null ) {
 586+ global $wgUser;
 587+ $user = $wgUser;
 588+ }
 589+ return $user->isAllowed( $permission );
586590 } else {
587591 return true;
588592 }
Index: trunk/phase3/includes/Revision.php
@@ -490,14 +490,14 @@
491491 * Revision::FOR_PUBLIC to be displayed to all users
492492 * Revision::FOR_THIS_USER to be displayed to $wgUser
493493 * Revision::RAW get the ID regardless of permissions
494 - *
495 - *
 494+ * @param $user User object to check for, only if FOR_THIS_USER is passed
 495+ * to the $audience parameter
496496 * @return Integer
497497 */
498 - public function getUser( $audience = self::FOR_PUBLIC ) {
 498+ public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
499499 if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
500500 return 0;
501 - } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) {
 501+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) {
502502 return 0;
503503 } else {
504504 return $this->mUser;
@@ -522,13 +522,14 @@
523523 * Revision::FOR_PUBLIC to be displayed to all users
524524 * Revision::FOR_THIS_USER to be displayed to $wgUser
525525 * Revision::RAW get the text regardless of permissions
526 - *
 526+ * @param $user User object to check for, only if FOR_THIS_USER is passed
 527+ * to the $audience parameter
527528 * @return string
528529 */
529 - public function getUserText( $audience = self::FOR_PUBLIC ) {
 530+ public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
530531 if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
531532 return '';
532 - } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) {
 533+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) {
533534 return '';
534535 } else {
535536 return $this->mUserText;
@@ -553,13 +554,14 @@
554555 * Revision::FOR_PUBLIC to be displayed to all users
555556 * Revision::FOR_THIS_USER to be displayed to $wgUser
556557 * Revision::RAW get the text regardless of permissions
557 - *
 558+ * @param $user User object to check for, only if FOR_THIS_USER is passed
 559+ * to the $audience parameter
558560 * @return String
559561 */
560 - function getComment( $audience = self::FOR_PUBLIC ) {
 562+ function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
561563 if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) {
562564 return '';
563 - } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT ) ) {
 565+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT, $user ) ) {
564566 return '';
565567 } else {
566568 return $this->mComment;
@@ -630,13 +632,14 @@
631633 * Revision::FOR_PUBLIC to be displayed to all users
632634 * Revision::FOR_THIS_USER to be displayed to $wgUser
633635 * Revision::RAW get the text regardless of permissions
634 - *
 636+ * @param $user User object to check for, only if FOR_THIS_USER is passed
 637+ * to the $audience parameter
635638 * @return String
636639 */
637 - public function getText( $audience = self::FOR_PUBLIC ) {
 640+ public function getText( $audience = self::FOR_PUBLIC, User $user = null ) {
638641 if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) {
639642 return '';
640 - } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT ) ) {
 643+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT, $user ) ) {
641644 return '';
642645 } else {
643646 return $this->getRawText();
@@ -1023,10 +1026,11 @@
10241027 * @param $field Integer:one of self::DELETED_TEXT,
10251028 * self::DELETED_COMMENT,
10261029 * self::DELETED_USER
 1030+ * @param $user User object to check, or null to use $wgUser
10271031 * @return Boolean
10281032 */
1029 - public function userCan( $field ) {
1030 - return self::userCanBitfield( $this->mDeleted, $field );
 1033+ public function userCan( $field, User $user = null ) {
 1034+ return self::userCanBitfield( $this->mDeleted, $field, $user );
10311035 }
10321036
10331037 /**
@@ -1038,11 +1042,11 @@
10391043 * @param $field Integer: one of self::DELETED_TEXT = File::DELETED_FILE,
10401044 * self::DELETED_COMMENT = File::DELETED_COMMENT,
10411045 * self::DELETED_USER = File::DELETED_USER
 1046+ * @param $user User object to check, or null to use $wgUser
10421047 * @return Boolean
10431048 */
1044 - public static function userCanBitfield( $bitfield, $field ) {
 1049+ public static function userCanBitfield( $bitfield, $field, User $user = null ) {
10451050 if( $bitfield & $field ) { // aspect is deleted
1046 - global $wgUser;
10471051 if ( $bitfield & self::DELETED_RESTRICTED ) {
10481052 $permission = 'suppressrevision';
10491053 } elseif ( $field & self::DELETED_TEXT ) {
@@ -1051,7 +1055,11 @@
10521056 $permission = 'deletedhistory';
10531057 }
10541058 wfDebug( "Checking for $permission due to $field match on $bitfield\n" );
1055 - return $wgUser->isAllowed( $permission );
 1059+ if ( $user === null ) {
 1060+ global $wgUser;
 1061+ $user = $wgUser;
 1062+ }
 1063+ return $user->isAllowed( $permission );
10561064 } else {
10571065 return true;
10581066 }
Index: trunk/phase3/includes/ChangesList.php
@@ -262,7 +262,7 @@
263263 # Diff link
264264 if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
265265 $diffLink = $this->message['diff'];
266 - } elseif( !self::userCan($rc,Revision::DELETED_TEXT) ) {
 266+ } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
267267 $diffLink = $this->message['diff'];
268268 } else {
269269 $query = array(
@@ -422,13 +422,14 @@
423423 * field of this revision, if it's marked as deleted.
424424 * @param $rc RCCacheEntry
425425 * @param $field Integer
 426+ * @param $user User object to check, or null to use $wgUser
426427 * @return Boolean
427428 */
428 - public static function userCan( $rc, $field ) {
 429+ public static function userCan( $rc, $field, User $user = null ) {
429430 if( $rc->mAttribs['rc_type'] == RC_LOG ) {
430 - return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field );
 431+ return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
431432 } else {
432 - return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field );
 433+ return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
433434 }
434435 }
435436
@@ -675,7 +676,7 @@
676677 }
677678
678679 # Don't show unusable diff links
679 - if ( !ChangesList::userCan($rc,Revision::DELETED_TEXT) ) {
 680+ if ( !ChangesList::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
680681 $showdifflinks = false;
681682 }
682683
@@ -883,7 +884,7 @@
884885 $r .= ' ';
885886 if( !$allLogs ) {
886887 $r .= '(';
887 - if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) {
 888+ if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
888889 $r .= $nchanges[$n];
889890 } elseif( $isnew ) {
890891 $r .= $nchanges[$n];
@@ -972,7 +973,7 @@
973974 if( $type == RC_LOG ) {
974975 $link = $rcObj->timestamp;
975976 # Revision link
976 - } elseif( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
 977+ } elseif( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
977978 $link = '<span class="history-deleted">'.$rcObj->timestamp.'</span> ';
978979 } else {
979980 if ( $rcObj->unpatrolled && $type == RC_NEW) {
Index: trunk/phase3/includes/specials/SpecialUndelete.php
@@ -634,7 +634,9 @@
635635
636636 function execute( $par ) {
637637 $this->setHeaders();
638 - if ( !$this->userCanExecute( $this->getUser() ) ) {
 638+
 639+ $user = $this->getUser();
 640+ if ( !$this->userCanExecute( $user ) ) {
639641 $this->displayRestrictionError();
640642 return;
641643 }
@@ -663,7 +665,7 @@
664666
665667 if( is_null( $this->mTargetObj ) ) {
666668 # Not all users can just browse every deleted page from the list
667 - if( $this->getUser()->isAllowed( 'browsearchive' ) ) {
 669+ if( $user->isAllowed( 'browsearchive' ) ) {
668670 $this->showSearchForm();
669671
670672 # List undeletable articles
@@ -685,14 +687,14 @@
686688 if ( !$file->exists() ) {
687689 $out->addWikiMsg( 'filedelete-nofile', $this->mFilename );
688690 return;
689 - } elseif( !$file->userCan( File::DELETED_FILE ) ) {
 691+ } elseif( !$file->userCan( File::DELETED_FILE, $user ) ) {
690692 if( $file->isDeleted( File::DELETED_RESTRICTED ) ) {
691693 $out->permissionRequired( 'suppressrevision' );
692694 } else {
693695 $out->permissionRequired( 'deletedtext' );
694696 }
695697 return false;
696 - } elseif ( !$this->getUser()->matchEditToken( $this->mToken, $this->mFilename ) ) {
 698+ } elseif ( !$user->matchEditToken( $this->mToken, $this->mFilename ) ) {
697699 $this->showFileConfirmationForm( $this->mFilename );
698700 return false;
699701 } else {
@@ -772,8 +774,6 @@
773775 }
774776
775777 private function showRevision( $timestamp ) {
776 - $out = $this->getOutput();
777 -
778778 if( !preg_match( '/[0-9]{14}/', $timestamp ) ) {
779779 return 0;
780780 }
@@ -782,13 +782,16 @@
783783 wfRunHooks( 'UndeleteForm::showRevision', array( &$archive, $this->mTargetObj ) );
784784 $rev = $archive->getRevision( $timestamp );
785785
 786+ $out = $this->getOutput();
 787+ $user = $this->getUser();
 788+
786789 if( !$rev ) {
787790 $out->addWikiMsg( 'undeleterevision-missing' );
788791 return;
789792 }
790793
791794 if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
792 - if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
 795+ if( !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
793796 $out->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
794797 return;
795798 } else {
@@ -804,7 +807,7 @@
805808 $previousRev = $archive->getPreviousRevision( $timestamp );
806809 if( $previousRev ) {
807810 $this->showDiff( $previousRev, $rev );
808 - if( $this->getUser()->getOption( 'diffonly' ) ) {
 811+ if( $user->getOption( 'diffonly' ) ) {
809812 return;
810813 } else {
811814 $out->addHTML( '<hr />' );
@@ -824,7 +827,7 @@
825828 $time = $this->getLang()->timeAndDate( $timestamp, true );
826829 $d = $this->getLang()->date( $timestamp, true );
827830 $t = $this->getLang()->time( $timestamp, true );
828 - $user = Linker::revUserTools( $rev );
 831+ $userLink = Linker::revUserTools( $rev );
829832
830833 if( $this->mPreview ) {
831834 $openDiv = '<div id="mw-undelete-revision" class="mw-warning">';
@@ -835,14 +838,14 @@
836839
837840 // Revision delete links
838841 if ( !$this->mDiff ) {
839 - $revdel = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj );
 842+ $revdel = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj );
840843 if ( $revdel ) {
841844 $out->addHTML( "$revdel " );
842845 }
843846 }
844847
845848 $out->addHTML( wfMessage( 'undelete-revision' )->rawParams( $link )->params(
846 - $time )->rawParams( $user )->params( $d, $t )->parse() . '</div>' );
 849+ $time )->rawParams( $userLink )->params( $d, $t )->parse() . '</div>' );
847850 wfRunHooks( 'UndeleteShowRevision', array( $this->mTargetObj, $rev ) );
848851
849852 if( $this->mPreview ) {
@@ -850,15 +853,15 @@
851854 $popts = $out->parserOptions();
852855 $popts->setEditSection( false );
853856 $out->parserOptions( $popts );
854 - $out->addWikiTextTitleTidy( $rev->getText( Revision::FOR_THIS_USER ), $this->mTargetObj, true );
 857+ $out->addWikiTextTitleTidy( $rev->getText( Revision::FOR_THIS_USER, $user ), $this->mTargetObj, true );
855858 }
856859
857860 $out->addHTML(
858861 Xml::element( 'textarea', array(
859862 'readonly' => 'readonly',
860 - 'cols' => intval( $this->getUser()->getOption( 'cols' ) ),
861 - 'rows' => intval( $this->getUser()->getOption( 'rows' ) ) ),
862 - $rev->getText( Revision::FOR_THIS_USER ) . "\n" ) .
 863+ 'cols' => intval( $user->getOption( 'cols' ) ),
 864+ 'rows' => intval( $user->getOption( 'rows' ) ) ),
 865+ $rev->getText( Revision::FOR_THIS_USER, $user ) . "\n" ) .
863866 Xml::openElement( 'div' ) .
864867 Xml::openElement( 'form', array(
865868 'method' => 'post',
@@ -874,7 +877,7 @@
875878 Xml::element( 'input', array(
876879 'type' => 'hidden',
877880 'name' => 'wpEditToken',
878 - 'value' => $this->getUser()->editToken() ) ) .
 881+ 'value' => $user->editToken() ) ) .
879882 Xml::element( 'input', array(
880883 'type' => 'submit',
881884 'name' => 'preview',
@@ -1189,7 +1192,7 @@
11901193 if( $this->mCanView ) {
11911194 $titleObj = $this->getTitle();
11921195 # Last link
1193 - if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
 1196+ if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
11941197 $pageLink = htmlspecialchars( $this->getLang()->timeanddate( $ts, true ) );
11951198 $last = wfMsgHtml( 'diff' );
11961199 } elseif( $remaining > 0 || ( $earliestLiveTime && $ts > $earliestLiveTime ) ) {
@@ -1250,9 +1253,10 @@
12511254 $comment = $this->getFileComment( $file );
12521255
12531256 // Add show/hide deletion links if available
1254 - $canHide = $this->getUser()->isAllowed( 'deleterevision' );
1255 - if( $canHide || ( $file->getVisibility() && $this->getUser()->isAllowed( 'deletedhistory' ) ) ) {
1256 - if( !$file->userCan( File::DELETED_RESTRICTED ) ) {
 1257+ $user = $this->getUser();
 1258+ $canHide = $user->isAllowed( 'deleterevision' );
 1259+ if( $canHide || ( $file->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
 1260+ if( !$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
12571261 $revdlink = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
12581262 } else {
12591263 $query = array(
@@ -1279,7 +1283,7 @@
12801284 function getPageLink( $rev, $titleObj, $ts ) {
12811285 $time = htmlspecialchars( $this->getLang()->timeanddate( $ts, true ) );
12821286
1283 - if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
 1287+ if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
12841288 return '<span class="history-deleted">' . $time . '</span>';
12851289 } else {
12861290 $link = Linker::linkKnown(
@@ -1305,7 +1309,7 @@
13061310 * @return String: HTML fragment
13071311 */
13081312 function getFileLink( $file, $titleObj, $ts, $key ) {
1309 - if( !$file->userCan( File::DELETED_FILE ) ) {
 1313+ if( !$file->userCan( File::DELETED_FILE, $this->getUser() ) ) {
13101314 return '<span class="history-deleted">' . $this->getLang()->timeanddate( $ts, true ) . '</span>';
13111315 } else {
13121316 $link = Linker::linkKnown(
@@ -1332,7 +1336,7 @@
13331337 * @return String: HTML fragment
13341338 */
13351339 function getFileUser( $file ) {
1336 - if( !$file->userCan( File::DELETED_USER ) ) {
 1340+ if( !$file->userCan( File::DELETED_USER, $this->getUser() ) ) {
13371341 return '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
13381342 } else {
13391343 $link = Linker::userLink( $file->getRawUser(), $file->getRawUserText() ) .
@@ -1351,7 +1355,7 @@
13521356 * @return String: HTML fragment
13531357 */
13541358 function getFileComment( $file ) {
1355 - if( !$file->userCan( File::DELETED_COMMENT ) ) {
 1359+ if( !$file->userCan( File::DELETED_COMMENT, $this->getUser() ) ) {
13561360 return '<span class="history-deleted"><span class="comment">' .
13571361 wfMsgHtml( 'rev-deleted-comment' ) . '</span></span>';
13581362 } else {
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -278,7 +278,7 @@
279279 $this->getOutput()->addWikiMsg( 'revdelete-no-file' );
280280 return;
281281 }
282 - if( !$oimage->userCan(File::DELETED_FILE) ) {
 282+ if( !$oimage->userCan( File::DELETED_FILE, $this->getUser() ) ) {
283283 if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
284284 $this->getOutput()->permissionRequired( 'suppressrevision' );
285285 } else {
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -616,8 +616,9 @@
617617 $topmarktext .= ' '.Linker::generateRollback( $rev );
618618 }
619619 }
 620+ $user = $this->getUser();
620621 # Is there a visible previous revision?
621 - if( $rev->userCan( Revision::DELETED_TEXT ) && $rev->getParentId() !== 0 ) {
 622+ if( $rev->userCan( Revision::DELETED_TEXT, $user ) && $rev->getParentId() !== 0 ) {
622623 $difftext = Linker::linkKnown(
623624 $page,
624625 $this->messages['diff'],
@@ -646,7 +647,7 @@
647648
648649 $comment = $this->getLang()->getDirMark() . Linker::revComment( $rev, false, true );
649650 $date = $this->getLang()->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
650 - if( $rev->userCan( Revision::DELETED_TEXT ) ) {
 651+ if( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
651652 $d = Linker::linkKnown(
652653 $page,
653654 htmlspecialchars($date),
@@ -680,9 +681,9 @@
681682 }
682683
683684 // Don't show useless link to people who cannot hide revisions
684 - $canHide = $this->getUser()->isAllowed( 'deleterevision' );
685 - if( $canHide || ($rev->getVisibility() && $this->getUser()->isAllowed('deletedhistory')) ) {
686 - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
 685+ $canHide = $user->isAllowed( 'deleterevision' );
 686+ if( $canHide || ($rev->getVisibility() && $user->isAllowed('deletedhistory')) ) {
 687+ if( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
687688 $del = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
688689 } else {
689690 $query = array(
Index: trunk/phase3/includes/specials/SpecialDeletedContributions.php
@@ -184,7 +184,7 @@
185185 $comment = Linker::revComment( $rev );
186186 $date = htmlspecialchars( $this->getLang()->timeanddate( $rev->getTimestamp(), true ) );
187187
188 - if( !$user->isAllowed('undelete') || !$rev->userCan(Revision::DELETED_TEXT) ) {
 188+ if( !$user->isAllowed( 'undelete' ) || !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
189189 $link = $date; // unusable link
190190 } else {
191191 $link = Linker::linkKnown(
Index: trunk/phase3/includes/specials/SpecialMergeHistory.php
@@ -271,7 +271,7 @@
272272 }
273273
274274 # Last link
275 - if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
 275+ if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
276276 $last = $this->message['last'];
277277 } elseif( isset( $this->prevId[$row->rev_id] ) ) {
278278 $last = Linker::linkKnown(
Index: trunk/phase3/includes/RevisionList.php
@@ -300,11 +300,11 @@
301301 }
302302
303303 public function canView() {
304 - return $this->revision->userCan( Revision::DELETED_RESTRICTED );
 304+ return $this->revision->userCan( Revision::DELETED_RESTRICTED, $this->context->getUser() );
305305 }
306306
307307 public function canViewContent() {
308 - return $this->revision->userCan( Revision::DELETED_TEXT );
 308+ return $this->revision->userCan( Revision::DELETED_TEXT, $this->context->getUser() );
309309 }
310310
311311 public function isDeleted() {

Sign-offs

UserFlagDate
Nikerabbitinspected16:40, 12 October 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r111950r99633: Fixed raw access to context field, which is lazy-loaded and thus the ...aaron18:39, 20 February 2012

Comments

#Comment by Aaron Schulz (talk | contribs)   18:02, 27 October 2011

Why not just allow passing a User as $audience instead?

Status & tagging log