r87806 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87805‎ | r87806 | r87807 >
Date:01:17, 10 May 2011
Author:brion
Status:resolved (Comments)
Tags:
Comment:
* (bug 21279, bug 28820) Workaround for standard diff links to deleted revs; Special:Undelete links to deleted rev when allowed.

Adds links to Special:Undelete to view the requested revisions onto the 'revision data not found' error message, if they can be found via ar_rev_id and the user has permission to deletedhistory.

Follow-up to r87804; allows the 'diff' links on log entries for Special:RevisionDelete actions on deleted revs referenced by rev-id to continue to go someplace semi-sane.
Could benefit a more transparent forwarding -> bug 28820.
Modified paths:
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -119,6 +119,47 @@
120120 return $this->mNewid;
121121 }
122122
 123+ /**
 124+ * Look up a special:Undelete link to the given deleted revision id,
 125+ * as a workaround for being unable to load deleted diffs in currently.
 126+ *
 127+ * @param int $id revision ID
 128+ * @return mixed URL or false
 129+ */
 130+ function deletedLink( $id ) {
 131+ global $wgUser;
 132+ if ( $wgUser->isAllowed( 'deletedhistory' ) ) {
 133+ $dbr = wfGetDB( DB_SLAVE );
 134+ $row = $dbr->selectRow('archive', '*',
 135+ array( 'ar_rev_id' => $id ),
 136+ __METHOD__ );
 137+ if ( $row ) {
 138+ $rev = Revision::newFromArchiveRow( $row );
 139+ $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
 140+ return SpecialPage::getTitleFor( 'Undelete' )->getFullURL( array(
 141+ 'target' => $title->getPrefixedText(),
 142+ 'timestamp' => $rev->getTimestamp()
 143+ ));
 144+ }
 145+ }
 146+ return false;
 147+ }
 148+
 149+ /**
 150+ * Build a wikitext link toward a deleted revision, if viewable.
 151+ *
 152+ * @param int $id revision ID
 153+ * @return string wikitext fragment
 154+ */
 155+ function deletedIdMarker( $id ) {
 156+ $link = $this->deletedLink( $id );
 157+ if ( $link ) {
 158+ return "[$link $id]";
 159+ } else {
 160+ return $id;
 161+ }
 162+ }
 163+
123164 function showDiffPage( $diffOnly = false ) {
124165 global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol;
125166 wfProfileIn( __METHOD__ );
@@ -165,10 +206,15 @@
166207
167208 $wgOut->setArticleFlag( false );
168209 if ( !$this->loadRevisionData() ) {
 210+ // Sounds like a deleted revision... Let's see what we can do.
 211+ $deletedLink = $this->deletedLink( $this->mNewid );
 212+
169213 $t = $this->mTitle->getPrefixedText();
170 - $d = wfMsgExt( 'missingarticle-diff', array( 'escape' ), $this->mOldid, $this->mNewid );
 214+ $d = wfMsgExt( 'missingarticle-diff', array( 'escape' ),
 215+ $this->deletedIdMarker( $this->mOldid ),
 216+ $this->deletedIdMarker( $this->mNewid ) );
171217 $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) );
172 - $wgOut->addWikiMsg( 'missing-article', "<nowiki>$t</nowiki>", $d );
 218+ $wgOut->addWikiMsg( 'missing-article', "<nowiki>$t</nowiki>", "<span class='plainlinks'>$d</span>" );
173219 wfProfileOut( __METHOD__ );
174220 return;
175221 }
@@ -520,9 +566,11 @@
521567 #
522568 if ( ! $this->loadNewText() ) {
523569 $t = $this->mTitle->getPrefixedText();
524 - $d = wfMsgExt( 'missingarticle-diff', array( 'escape' ), $this->mOldid, $this->mNewid );
 570+ $d = wfMsgExt( 'missingarticle-diff', array( 'escape' ),
 571+ $this->deletedIdMarker( $this->mOldid ),
 572+ $this->deletedIdMarker( $this->mNewid ) );
525573 $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) );
526 - $wgOut->addWikiMsg( 'missing-article', "<nowiki>$t</nowiki>", $d );
 574+ $wgOut->addWikiMsg( 'missing-article', "<nowiki>$t</nowiki>", "<span class='plainlinks'>$d</span>" );
527575 wfProfileOut( __METHOD__ );
528576 return;
529577 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r91348Removed some dead code (useless since r87806)aaron09:12, 2 July 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
r87805* (bug 21279) Special:Undelete's 'change visibility' links now use forward-co...brion01:13, 10 May 2011

Comments

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

$deletedLink = $this->deletedLink( $this->mNewid );

This doesn't do anything.

Status & tagging log