Index: trunk/phase3/maintenance/tables.sql |
— | — | @@ -412,11 +412,12 @@ |
413 | 413 | ar_page_id int unsigned, |
414 | 414 | |
415 | 415 | -- Original previous revision |
416 | | - ar_parent_id int unsigned default NULL |
| 416 | + ar_parent_id int unsigned default NULL, |
417 | 417 | ) /*$wgDBTableOptions*/; |
418 | 418 | |
419 | 419 | CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp); |
420 | 420 | 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); |
421 | 422 | |
422 | 423 | |
423 | 424 | -- |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | if( !isset( $this->message ) ) { |
43 | 43 | $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink', |
44 | 44 | 'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'hist', 'diff', |
45 | | - 'pipe-separator' ); |
| 45 | + 'pipe-separator', 'revdel-restore-deleted', 'revdel-restore-visible' ); |
46 | 46 | foreach( $messages as $msg ) { |
47 | 47 | $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) ); |
48 | 48 | } |
— | — | @@ -450,57 +450,8 @@ |
451 | 451 | ) . ')'; |
452 | 452 | // If an edit was hidden from a page give a review link to the history |
453 | 453 | } 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 ); |
505 | 456 | // Hidden log items, give review link |
506 | 457 | } else if( self::typeAction( $row, array( 'delete', 'suppress' ), 'event', 'deletedhistory' ) ) { |
507 | 458 | if( count($paramArray) >= 1 ) { |
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -719,6 +719,143 @@ |
720 | 720 | return null; |
721 | 721 | } |
722 | 722 | } |
| 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 | + } |
723 | 860 | } |
724 | 861 | |
725 | 862 | /** |