Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -119,6 +119,47 @@ |
120 | 120 | return $this->mNewid; |
121 | 121 | } |
122 | 122 | |
| 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 | + |
123 | 164 | function showDiffPage( $diffOnly = false ) { |
124 | 165 | global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol; |
125 | 166 | wfProfileIn( __METHOD__ ); |
— | — | @@ -165,10 +206,15 @@ |
166 | 207 | |
167 | 208 | $wgOut->setArticleFlag( false ); |
168 | 209 | if ( !$this->loadRevisionData() ) { |
| 210 | + // Sounds like a deleted revision... Let's see what we can do. |
| 211 | + $deletedLink = $this->deletedLink( $this->mNewid ); |
| 212 | + |
169 | 213 | $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 ) ); |
171 | 217 | $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>" ); |
173 | 219 | wfProfileOut( __METHOD__ ); |
174 | 220 | return; |
175 | 221 | } |
— | — | @@ -520,9 +566,11 @@ |
521 | 567 | # |
522 | 568 | if ( ! $this->loadNewText() ) { |
523 | 569 | $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 ) ); |
525 | 573 | $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>" ); |
527 | 575 | wfProfileOut( __METHOD__ ); |
528 | 576 | return; |
529 | 577 | } |