r66793 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66792‎ | r66793 | r66794 >
Date:14:19, 23 May 2010
Author:werdna
Status:resolved
Tags:
Comment:
Ugly temporary fix for bug 21279:
* When a revision cannot be found in the revision table, look for it in the archive table.
* If both deleted and undeleted revisions are covered by the same log entry, show two links (see bug 23663)
Modified paths:
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tables.sql
@@ -412,11 +412,12 @@
413413 ar_page_id int unsigned,
414414
415415 -- Original previous revision
416 - ar_parent_id int unsigned default NULL
 416+ ar_parent_id int unsigned default NULL,
417417 ) /*$wgDBTableOptions*/;
418418
419419 CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
420420 CREATE INDEX /*i*/ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
 421+CREATE INDEX /*i*/ar_page_revid ON /*_*/archive (ar_namespace, ar_title, ar_id);
421422
422423
423424 --
Index: trunk/phase3/includes/LogEventsList.php
@@ -41,7 +41,7 @@
4242 if( !isset( $this->message ) ) {
4343 $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
4444 'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'hist', 'diff',
45 - 'pipe-separator' );
 45+ 'pipe-separator', 'revdel-restore-deleted', 'revdel-restore-visible' );
4646 foreach( $messages as $msg ) {
4747 $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
4848 }
@@ -450,57 +450,8 @@
451451 ) . ')';
452452 // If an edit was hidden from a page give a review link to the history
453453 } else if( self::typeAction( $row, array( 'delete', 'suppress' ), 'revision', 'deletedhistory' ) ) {
454 - if( count($paramArray) >= 2 ) {
455 - // Different revision types use different URL params...
456 - $key = $paramArray[0];
457 - // $paramArray[1] is a CSV of the IDs
458 - $Ids = explode( ',', $paramArray[1] );
459 - $query = $paramArray[1];
460 - $revert = array();
461 - // Diff link for single rev deletions
462 - if( count($Ids) == 1 ) {
463 - // Live revision diffs...
464 - if( in_array( $key, array( 'oldid', 'revision' ) ) ) {
465 - $revert[] = $this->skin->link(
466 - $title,
467 - $this->message['diff'],
468 - array(),
469 - array(
470 - 'diff' => intval( $Ids[0] ),
471 - 'unhide' => 1
472 - ),
473 - array( 'known', 'noclasses' )
474 - );
475 - // Deleted revision diffs...
476 - } else if( in_array( $key, array( 'artimestamp','archive' ) ) ) {
477 - $revert[] = $this->skin->link(
478 - SpecialPage::getTitleFor( 'Undelete' ),
479 - $this->message['diff'],
480 - array(),
481 - array(
482 - 'target' => $title->getPrefixedDBKey(),
483 - 'diff' => 'prev',
484 - 'timestamp' => $Ids[0]
485 - ),
486 - array( 'known', 'noclasses' )
487 - );
488 - }
489 - }
490 - // View/modify link...
491 - $revert[] = $this->skin->link(
492 - SpecialPage::getTitleFor( 'Revisiondelete' ),
493 - $this->message['revdel-restore'],
494 - array(),
495 - array(
496 - 'target' => $title->getPrefixedText(),
497 - 'type' => $key,
498 - 'ids' => $query
499 - ),
500 - array( 'known', 'noclasses' )
501 - );
502 - // Pipe links
503 - $revert = wfMsg( 'parentheses', $wgLang->pipeList( $revert ) );
504 - }
 454+ $revert = RevisionDeleter::getLogLinks( $title, $paramArray,
 455+ $this->skin, $this->message );
505456 // Hidden log items, give review link
506457 } else if( self::typeAction( $row, array( 'delete', 'suppress' ), 'event', 'deletedhistory' ) ) {
507458 if( count($paramArray) >= 1 ) {
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -719,6 +719,143 @@
720720 return null;
721721 }
722722 }
 723+
 724+ // Checks if a revision still exists in the revision table.
 725+ // If it doesn't, returns the corresponding ar_timestamp field
 726+ // so that this key can be used instead.
 727+ public static function checkRevisionExistence( $title, $revid ) {
 728+ $dbr = wfGetDB( DB_SLAVE );
 729+ $exists = $dbr->selectField( 'revision', '1',
 730+ array( 'rev_id' => $revid ), __METHOD__ );
 731+
 732+ if ( $exists ) {
 733+ return true;
 734+ }
 735+
 736+ $timestamp = $dbr->selectField( 'archive', 'ar_timestamp',
 737+ array( 'ar_namespace' => $title->getNamespace(),
 738+ 'ar_title' => $title->getDBkey(),
 739+ 'ar_rev_id' => $revid ), __METHOD__ );
 740+
 741+ return $timestamp;
 742+ }
 743+
 744+ // Creates utility links for log entries.
 745+ public static function getLogLinks( $title, $paramArray, $skin, $messages ) {
 746+ global $wgLang;
 747+
 748+ if( count($paramArray) >= 2 ) {
 749+ // Different revision types use different URL params...
 750+ $originalKey = $key = $paramArray[0];
 751+ // $paramArray[1] is a CSV of the IDs
 752+ $Ids = explode( ',', $paramArray[1] );
 753+ $query = $paramArray[1];
 754+ $revert = array();
 755+
 756+ // For if undeleted revisions are found amidst deleted ones.
 757+ $undeletedRevisions = array();
 758+
 759+ // This is not going to work if some revs are deleted and some
 760+ // aren't.
 761+ if ($key == 'revision') {
 762+ foreach( $Ids as $k => $id ) {
 763+ $existResult =
 764+ self::checkRevisionExistence( $title, $id );
 765+
 766+ if ($existResult !== true) {
 767+ $key = 'archive';
 768+ $Ids[$k] = $existResult;
 769+ } elseif ($key != $originalKey) {
 770+ // Undeleted revision amidst deleted ones
 771+ unset($Ids[$k]);
 772+ $undeletedRevisions[] = $id;
 773+ }
 774+ }
 775+ }
 776+
 777+ // Diff link for single rev deletions
 778+ if( count($Ids) == 1 && !count($undeletedRevisions) ) {
 779+ // Live revision diffs...
 780+ if( in_array( $key, array( 'oldid', 'revision' ) ) ) {
 781+ $revert[] = $skin->link(
 782+ $title,
 783+ $messages['diff'],
 784+ array(),
 785+ array(
 786+ 'diff' => intval( $Ids[0] ),
 787+ 'unhide' => 1
 788+ ),
 789+ array( 'known', 'noclasses' )
 790+ );
 791+ // Deleted revision diffs...
 792+ } else if( in_array( $key, array( 'artimestamp','archive' ) ) ) {
 793+ $revert[] = $skin->link(
 794+ SpecialPage::getTitleFor( 'Undelete' ),
 795+ $messages['diff'],
 796+ array(),
 797+ array(
 798+ 'target' => $title->getPrefixedDBKey(),
 799+ 'diff' => 'prev',
 800+ 'timestamp' => $Ids[0]
 801+ ),
 802+ array( 'known', 'noclasses' )
 803+ );
 804+ }
 805+ }
 806+
 807+ // View/modify link...
 808+ if ( count($undeletedRevisions) ) {
 809+ // FIXME THIS IS A HORRIBLE HORRIBLE HACK AND SHOULD DIE
 810+ // It's not possible to pass a list of both deleted and
 811+ // undeleted revisions to SpecialRevisionDelete, so we're
 812+ // stuck with two links. See bug
 813+ $restoreLinks = array();
 814+
 815+ $restoreLinks[] = $skin->link(
 816+ SpecialPage::getTitleFor( 'Revisiondelete' ),
 817+ $messages['revdel-restore-visible'],
 818+ array(),
 819+ array(
 820+ 'target' => $title->getPrefixedText(),
 821+ 'type' => $originalKey,
 822+ 'ids' => implode(',', $undeletedRevisions),
 823+ ),
 824+ array( 'known', 'noclasses' )
 825+ );
 826+
 827+ $restoreLinks[] = $skin->link(
 828+ SpecialPage::getTitleFor( 'Revisiondelete' ),
 829+ $messages['revdel-restore-deleted'],
 830+ array(),
 831+ array(
 832+ 'target' => $title->getPrefixedText(),
 833+ 'type' => $key,
 834+ 'ids' => implode(',', $Ids),
 835+ ),
 836+ array( 'known', 'noclasses' )
 837+ );
 838+
 839+ $revert[] = $messages['revdel-restore'] . ' [' .
 840+ $wgLang->pipeList( $restoreLinks ) . ']';
 841+ } else {
 842+ $revert[] = $skin->link(
 843+ SpecialPage::getTitleFor( 'Revisiondelete' ),
 844+ $messages['revdel-restore'],
 845+ array(),
 846+ array(
 847+ 'target' => $title->getPrefixedText(),
 848+ 'type' => $key,
 849+ 'ids' => implode(',', $Ids),
 850+ ),
 851+ array( 'known', 'noclasses' )
 852+ );
 853+ }
 854+
 855+ // Pipe links
 856+ $revert = wfMsg( 'parentheses', $wgLang->pipeList( $revert ) );
 857+ }
 858+ return $revert;
 859+ }
723860 }
724861
725862 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r66796Add bug # for r66793werdna14:24, 23 May 2010
r66823Add messages for r66793werdna12:47, 24 May 2010
r66904Merge r66823 and r66793werdna02:07, 26 May 2010
r66907Fix bug in r66793werdna05:50, 26 May 2010
r66908Fix conflict in r66907 (follow-up r66793) accidentally partially reverting r6...werdna05:52, 26 May 2010
r79746Followup r79702, r66793, r66822...reedy19:27, 6 January 2011
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
r93860* Refactored SpecialUndelete::revDeleteLink into a Linker::getRevDeleteLink f...aaron22:37, 3 August 2011

Status & tagging log