Index: trunk/phase3/includes/specials/SpecialUndelete.php |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | function listRevisions() { |
111 | 111 | $dbr = wfGetDB( DB_SLAVE ); |
112 | 112 | $res = $dbr->select( 'archive', |
113 | | - array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len', 'ar_deleted' ), |
| 113 | + array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id' ), |
114 | 114 | array( 'ar_namespace' => $this->title->getNamespace(), |
115 | 115 | 'ar_title' => $this->title->getDBkey() ), |
116 | 116 | 'PageArchive::listRevisions', |
— | — | @@ -819,18 +819,10 @@ |
820 | 820 | $wgOut->addHTML( $openDiv ); |
821 | 821 | |
822 | 822 | // Revision delete links |
823 | | - $canHide = $wgUser->isAllowed( 'deleterevision' ); |
824 | | - if ( !$this->mDiff && ( $canHide || ( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) ) { |
825 | | - if( !$rev->userCan(Revision::DELETED_RESTRICTED ) ) { |
826 | | - $wgOut->addHTML( $skin->revDeleteLinkDisabled( $canHide ) ); // revision was hidden from sysops |
827 | | - } else { |
828 | | - $query = array( |
829 | | - 'type' => 'archive', |
830 | | - 'target' => $this->mTargetObj->getPrefixedDBkey(), |
831 | | - 'ids' => $rev->getTimestamp() |
832 | | - ); |
833 | | - $wgOut->addHTML( $skin->revDeleteLink( $query, |
834 | | - $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide ) ); |
| 823 | + if ( !$this->mDiff ) { |
| 824 | + $revdel = $this->revDeleteLink( $rev ); |
| 825 | + if ( $revdel ) { |
| 826 | + $wgOut->addHTML( $revdel ); |
835 | 827 | } |
836 | 828 | } |
837 | 829 | |
— | — | @@ -881,6 +873,50 @@ |
882 | 874 | } |
883 | 875 | |
884 | 876 | /** |
| 877 | + * Get a revision-deletion link, or disabled link, or nothing, depending |
| 878 | + * on user permissions & the settings on the revision. |
| 879 | + * |
| 880 | + * Will use forward-compatible revision ID in the Special:RevDelete link |
| 881 | + * if possible, otherwise the timestamp-based ID which may break after |
| 882 | + * undeletion. |
| 883 | + * |
| 884 | + * @param Revision $rev |
| 885 | + * @return string HTML fragment |
| 886 | + */ |
| 887 | + function revDeleteLink( $rev ) { |
| 888 | + global $wgUser; |
| 889 | + $canHide = $wgUser->isAllowed( 'deleterevision' ); |
| 890 | + if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' )) ) { |
| 891 | + $skin = $wgUser->getSkin(); |
| 892 | + if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
| 893 | + $revdlink = $skin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops |
| 894 | + } else { |
| 895 | + if ( $rev->getId() ) { |
| 896 | + // RevDelete links using revision ID are stable across |
| 897 | + // page deletion and undeletion; use when possible. |
| 898 | + $query = array( |
| 899 | + 'type' => 'revision', |
| 900 | + 'target' => $this->mTargetObj->getPrefixedDBkey(), |
| 901 | + 'ids' => $rev->getId() |
| 902 | + ); |
| 903 | + } else { |
| 904 | + // Older deleted entries didn't save a revision ID. |
| 905 | + // We have to refer to these by timestamp, ick! |
| 906 | + $query = array( |
| 907 | + 'type' => 'archive', |
| 908 | + 'target' => $this->mTargetObj->getPrefixedDBkey(), |
| 909 | + 'ids' => $rev->getTimestamp() |
| 910 | + ); |
| 911 | + } |
| 912 | + return $skin->revDeleteLink( $query, |
| 913 | + $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide ); |
| 914 | + } |
| 915 | + } else { |
| 916 | + return ''; |
| 917 | + } |
| 918 | + } |
| 919 | + |
| 920 | + /** |
885 | 921 | * Build a diff display between this and the previous either deleted |
886 | 922 | * or non-deleted edit. |
887 | 923 | * |
— | — | @@ -937,23 +973,7 @@ |
938 | 974 | $targetQuery = array( 'oldid' => $rev->getId() ); |
939 | 975 | } |
940 | 976 | // Add show/hide deletion links if available |
941 | | - $canHide = $wgUser->isAllowed( 'deleterevision' ); |
942 | | - if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) { |
943 | | - $del = ' '; |
944 | | - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
945 | | - $del .= $sk->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops |
946 | | - } else { |
947 | | - $query = array( |
948 | | - 'type' => 'archive', |
949 | | - 'target' => $this->mTargetObj->getPrefixedDbkey(), |
950 | | - 'ids' => $rev->getTimestamp() |
951 | | - ); |
952 | | - $del .= $sk->revDeleteLink( $query, |
953 | | - $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide ); |
954 | | - } |
955 | | - } else { |
956 | | - $del = ''; |
957 | | - } |
| 977 | + $del .= $this->revDeleteLink( $rev ); |
958 | 978 | return |
959 | 979 | '<div id="mw-diff-'.$prefix.'title1"><strong>' . |
960 | 980 | $sk->link( |
— | — | @@ -1236,22 +1256,7 @@ |
1237 | 1257 | // Edit summary |
1238 | 1258 | $comment = $sk->revComment( $rev ); |
1239 | 1259 | // Revision delete links |
1240 | | - $canHide = $wgUser->isAllowed( 'deleterevision' ); |
1241 | | - if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' )) ) { |
1242 | | - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
1243 | | - $revdlink = $sk->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops |
1244 | | - } else { |
1245 | | - $query = array( |
1246 | | - 'type' => 'archive', |
1247 | | - 'target' => $this->mTargetObj->getPrefixedDBkey(), |
1248 | | - 'ids' => $ts |
1249 | | - ); |
1250 | | - $revdlink = $sk->revDeleteLink( $query, |
1251 | | - $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide ); |
1252 | | - } |
1253 | | - } else { |
1254 | | - $revdlink = ''; |
1255 | | - } |
| 1260 | + $revdlink = $this->revDeleteLink( $rev ); |
1256 | 1261 | return "<li>$checkBox $revdlink ($last) $pageLink . . $userLink $stxt $comment</li>"; |
1257 | 1262 | } |
1258 | 1263 | |