r87805 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87804‎ | r87805 | r87806 >
Date:01:13, 10 May 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
* (bug 21279) Special:Undelete's 'change visibility' links now use forward-compatible format with revision ID when available

Requires r87804 updates for Special:RevisionDelete to accept incoming links with &type=revision for deleted revs.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUndelete.php
@@ -109,7 +109,7 @@
110110 function listRevisions() {
111111 $dbr = wfGetDB( DB_SLAVE );
112112 $res = $dbr->select( 'archive',
113 - array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len', 'ar_deleted' ),
 113+ array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id' ),
114114 array( 'ar_namespace' => $this->title->getNamespace(),
115115 'ar_title' => $this->title->getDBkey() ),
116116 'PageArchive::listRevisions',
@@ -819,18 +819,10 @@
820820 $wgOut->addHTML( $openDiv );
821821
822822 // Revision delete links
823 - $canHide = $wgUser->isAllowed( 'deleterevision' );
824 - if ( !$this->mDiff && ( $canHide || ( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) ) {
825 - if( !$rev->userCan(Revision::DELETED_RESTRICTED ) ) {
826 - $wgOut->addHTML( $skin->revDeleteLinkDisabled( $canHide ) ); // revision was hidden from sysops
827 - } else {
828 - $query = array(
829 - 'type' => 'archive',
830 - 'target' => $this->mTargetObj->getPrefixedDBkey(),
831 - 'ids' => $rev->getTimestamp()
832 - );
833 - $wgOut->addHTML( $skin->revDeleteLink( $query,
834 - $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide ) );
 823+ if ( !$this->mDiff ) {
 824+ $revdel = $this->revDeleteLink( $rev );
 825+ if ( $revdel ) {
 826+ $wgOut->addHTML( $revdel );
835827 }
836828 }
837829
@@ -881,6 +873,50 @@
882874 }
883875
884876 /**
 877+ * Get a revision-deletion link, or disabled link, or nothing, depending
 878+ * on user permissions & the settings on the revision.
 879+ *
 880+ * Will use forward-compatible revision ID in the Special:RevDelete link
 881+ * if possible, otherwise the timestamp-based ID which may break after
 882+ * undeletion.
 883+ *
 884+ * @param Revision $rev
 885+ * @return string HTML fragment
 886+ */
 887+ function revDeleteLink( $rev ) {
 888+ global $wgUser;
 889+ $canHide = $wgUser->isAllowed( 'deleterevision' );
 890+ if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' )) ) {
 891+ $skin = $wgUser->getSkin();
 892+ if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
 893+ $revdlink = $skin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
 894+ } else {
 895+ if ( $rev->getId() ) {
 896+ // RevDelete links using revision ID are stable across
 897+ // page deletion and undeletion; use when possible.
 898+ $query = array(
 899+ 'type' => 'revision',
 900+ 'target' => $this->mTargetObj->getPrefixedDBkey(),
 901+ 'ids' => $rev->getId()
 902+ );
 903+ } else {
 904+ // Older deleted entries didn't save a revision ID.
 905+ // We have to refer to these by timestamp, ick!
 906+ $query = array(
 907+ 'type' => 'archive',
 908+ 'target' => $this->mTargetObj->getPrefixedDBkey(),
 909+ 'ids' => $rev->getTimestamp()
 910+ );
 911+ }
 912+ return $skin->revDeleteLink( $query,
 913+ $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide );
 914+ }
 915+ } else {
 916+ return '';
 917+ }
 918+ }
 919+
 920+ /**
885921 * Build a diff display between this and the previous either deleted
886922 * or non-deleted edit.
887923 *
@@ -937,23 +973,7 @@
938974 $targetQuery = array( 'oldid' => $rev->getId() );
939975 }
940976 // Add show/hide deletion links if available
941 - $canHide = $wgUser->isAllowed( 'deleterevision' );
942 - if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
943 - $del = ' ';
944 - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
945 - $del .= $sk->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
946 - } else {
947 - $query = array(
948 - 'type' => 'archive',
949 - 'target' => $this->mTargetObj->getPrefixedDbkey(),
950 - 'ids' => $rev->getTimestamp()
951 - );
952 - $del .= $sk->revDeleteLink( $query,
953 - $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
954 - }
955 - } else {
956 - $del = '';
957 - }
 977+ $del .= $this->revDeleteLink( $rev );
958978 return
959979 '<div id="mw-diff-'.$prefix.'title1"><strong>' .
960980 $sk->link(
@@ -1236,22 +1256,7 @@
12371257 // Edit summary
12381258 $comment = $sk->revComment( $rev );
12391259 // Revision delete links
1240 - $canHide = $wgUser->isAllowed( 'deleterevision' );
1241 - if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' )) ) {
1242 - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
1243 - $revdlink = $sk->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
1244 - } else {
1245 - $query = array(
1246 - 'type' => 'archive',
1247 - 'target' => $this->mTargetObj->getPrefixedDBkey(),
1248 - 'ids' => $ts
1249 - );
1250 - $revdlink = $sk->revDeleteLink( $query,
1251 - $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
1252 - }
1253 - } else {
1254 - $revdlink = '';
1255 - }
 1260+ $revdlink = $this->revDeleteLink( $rev );
12561261 return "<li>$checkBox $revdlink ($last) $pageLink . . $userLink $stxt $comment</li>";
12571262 }
12581263

Follow-up revisions

RevisionCommit summaryAuthorDate
r87806* (bug 21279, bug 28820) Workaround for standard diff links to deleted revs; ...brion01:17, 10 May 2011
r88173Follow up r87805. Remove unused global.platonides13:12, 15 May 2011
r93860* Refactored SpecialUndelete::revDeleteLink into a Linker::getRevDeleteLink f...aaron22:37, 3 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66793Ugly temporary fix for bug 21279:...werdna14:19, 23 May 2010
r87804* (bug 21279) Special:RevisionDelete now uses revision ID for deleted-page re...brion01:11, 10 May 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   05:28, 22 June 2011

Looks good.

Status & tagging log