r93860 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93859‎ | r93860 | r93861 >
Date:22:37, 3 August 2011
Author:aaron
Status:ok
Tags:
Comment:
* Refactored SpecialUndelete::revDeleteLink into a Linker::getRevDeleteLink function
* (bug 21279) Updated DeletedContributions to use type=revision when possible (ar_rev_id exists)
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialDeletedContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -1769,6 +1769,50 @@
17701770 }
17711771
17721772 /**
 1773+ * Get a revision-deletion link, or disabled link, or nothing, depending
 1774+ * on user permissions & the settings on the revision.
 1775+ *
 1776+ * Will use forward-compatible revision ID in the Special:RevDelete link
 1777+ * if possible, otherwise the timestamp-based ID which may break after
 1778+ * undeletion.
 1779+ *
 1780+ * @param User $user
 1781+ * @param Revision $rev
 1782+ * @param Revision $title
 1783+ * @return string HTML fragment
 1784+ */
 1785+ public static function getRevDeleteLink( User $user, Revision $rev, Title $title ) {
 1786+ $canHide = $user->isAllowed( 'deleterevision' );
 1787+ if ( $canHide || ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
 1788+ if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
 1789+ $revdlink = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
 1790+ } else {
 1791+ if ( $rev->getId() ) {
 1792+ // RevDelete links using revision ID are stable across
 1793+ // page deletion and undeletion; use when possible.
 1794+ $query = array(
 1795+ 'type' => 'revision',
 1796+ 'target' => $title->getPrefixedDBkey(),
 1797+ 'ids' => $rev->getId()
 1798+ );
 1799+ } else {
 1800+ // Older deleted entries didn't save a revision ID.
 1801+ // We have to refer to these by timestamp, ick!
 1802+ $query = array(
 1803+ 'type' => 'archive',
 1804+ 'target' => $title->getPrefixedDBkey(),
 1805+ 'ids' => $rev->getTimestamp()
 1806+ );
 1807+ }
 1808+ return Linker::revDeleteLink( $query,
 1809+ $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide );
 1810+ }
 1811+ } else {
 1812+ return '';
 1813+ }
 1814+ }
 1815+
 1816+ /**
17731817 * Creates a (show/hide) link for deleting revisions/log entries
17741818 *
17751819 * @param $query Array: query parameters to be passed to link()
@@ -2003,4 +2047,3 @@
20042048 return call_user_func_array( array( 'Linker', $fname ), $args );
20052049 }
20062050 }
2007 -
Index: trunk/phase3/includes/specials/SpecialUndelete.php
@@ -844,9 +844,9 @@
845845
846846 // Revision delete links
847847 if ( !$this->mDiff ) {
848 - $revdel = $this->revDeleteLink( $rev );
 848+ $revdel = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj );
849849 if ( $revdel ) {
850 - $out->addHTML( $revdel );
 850+ $out->addHTML( "$revdel " );
851851 }
852852 }
853853
@@ -897,48 +897,6 @@
898898 }
899899
900900 /**
901 - * Get a revision-deletion link, or disabled link, or nothing, depending
902 - * on user permissions & the settings on the revision.
903 - *
904 - * Will use forward-compatible revision ID in the Special:RevDelete link
905 - * if possible, otherwise the timestamp-based ID which may break after
906 - * undeletion.
907 - *
908 - * @param Revision $rev
909 - * @return string HTML fragment
910 - */
911 - function revDeleteLink( $rev ) {
912 - $canHide = $this->getUser()->isAllowed( 'deleterevision' );
913 - if( $canHide || ( $rev->getVisibility() && $this->getUser()->isAllowed( 'deletedhistory' ) ) ) {
914 - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
915 - $revdlink = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
916 - } else {
917 - if ( $rev->getId() ) {
918 - // RevDelete links using revision ID are stable across
919 - // page deletion and undeletion; use when possible.
920 - $query = array(
921 - 'type' => 'revision',
922 - 'target' => $this->mTargetObj->getPrefixedDBkey(),
923 - 'ids' => $rev->getId()
924 - );
925 - } else {
926 - // Older deleted entries didn't save a revision ID.
927 - // We have to refer to these by timestamp, ick!
928 - $query = array(
929 - 'type' => 'archive',
930 - 'target' => $this->mTargetObj->getPrefixedDBkey(),
931 - 'ids' => $rev->getTimestamp()
932 - );
933 - }
934 - return Linker::revDeleteLink( $query,
935 - $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide );
936 - }
937 - } else {
938 - return '';
939 - }
940 - }
941 -
942 - /**
943901 * Build a diff display between this and the previous either deleted
944902 * or non-deleted edit.
945903 *
@@ -991,7 +949,8 @@
992950 $targetQuery = array( 'oldid' => $rev->getId() );
993951 }
994952 // Add show/hide deletion links if available
995 - $del = $this->revDeleteLink( $rev );
 953+ $rdel = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj );
 954+ if ( $rdel ) $rdel = " $rdel";
996955 return
997956 '<div id="mw-diff-' . $prefix . 'title1"><strong>' .
998957 Linker::link(
@@ -1011,7 +970,7 @@
1012971 Linker::revUserTools( $rev ) . '<br />' .
1013972 '</div>' .
1014973 '<div id="mw-diff-'.$prefix.'title3">' .
1015 - Linker::revComment( $rev ) . $del . '<br />' .
 974+ Linker::revComment( $rev ) . $rdel . '<br />' .
1016975 '</div>';
1017976 }
1018977
@@ -1274,7 +1233,7 @@
12751234 // Edit summary
12761235 $comment = Linker::revComment( $rev );
12771236 // Revision delete links
1278 - $revdlink = $this->revDeleteLink( $rev );
 1237+ $revdlink = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj );
12791238 return "<li>$checkBox $revdlink ($last) $pageLink . . $userLink $stxt $comment</li>";
12801239 }
12811240
@@ -1300,6 +1259,7 @@
13011260 ')';
13021261 $data = htmlspecialchars( $data );
13031262 $comment = $this->getFileComment( $file );
 1263+
13041264 // Add show/hide deletion links if available
13051265 $canHide = $this->getUser()->isAllowed( 'deleterevision' );
13061266 if( $canHide || ( $file->getVisibility() && $this->getUser()->isAllowed( 'deletedhistory' ) ) ) {
@@ -1317,6 +1277,7 @@
13181278 } else {
13191279 $revdlink = '';
13201280 }
 1281+
13211282 return "<li>$checkBox $revdlink $pageLink . . $userLink $data $comment</li>\n";
13221283 }
13231284
Index: trunk/phase3/includes/specials/SpecialDeletedContributions.php
@@ -213,21 +213,8 @@
214214 }
215215
216216 // Revision delete link
217 - $canHide = $wgUser->isAllowed( 'deleterevision' );
218 - if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
219 - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
220 - $del = $this->mSkin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
221 - } else {
222 - $query = array(
223 - 'type' => 'archive',
224 - 'target' => $page->getPrefixedDbkey(),
225 - 'ids' => $rev->getTimestamp() );
226 - $del = $this->mSkin->revDeleteLink( $query,
227 - $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide ) . ' ';
228 - }
229 - } else {
230 - $del = '';
231 - }
 217+ $del = Linker::getRevDeleteLink( $wgUser, $rev, $page );
 218+ if ( $del ) $del .= ' ';
232219
233220 $tools = Html::rawElement(
234221 'span',

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
r87805* (bug 21279) Special:Undelete's 'change visibility' links now use forward-co...brion01:13, 10 May 2011
r87806* (bug 21279, bug 28820) Workaround for standard diff links to deleted revs; ...brion01:17, 10 May 2011

Status & tagging log