http://www.mediawiki.org/wiki/Special:Code/MediaWiki/66904
Revision: 66904 Author: werdna Date: 2010-05-26 02:07:00 +0000 (Wed, 26 May 2010) Log Message: ----------- Merge r66823 and r66793 Modified Paths: -------------- branches/wmf/1.16wmf4/includes/LogEventsList.php branches/wmf/1.16wmf4/includes/specials/SpecialRevisiondelete.php branches/wmf/1.16wmf4/languages/messages/MessagesEn.php Property Changed: ---------------- branches/wmf/1.16wmf4/includes/LogEventsList.php branches/wmf/1.16wmf4/includes/specials/SpecialRevisiondelete.php branches/wmf/1.16wmf4/languages/messages/MessagesEn.php Modified: branches/wmf/1.16wmf4/includes/LogEventsList.php =================================================================== --- branches/wmf/1.16wmf4/includes/LogEventsList.php 2010-05-26 01:57:47 UTC (rev 66903) +++ branches/wmf/1.16wmf4/includes/LogEventsList.php 2010-05-26 02:07:00 UTC (rev 66904) @@ -40,7 +40,7 @@ if( !isset( $this->message ) ) { $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink', 'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'hist', 'diff', - 'pipe-separator' ); + 'pipe-separator', 'revdel-restore-deleted', 'revdel-restore-visible' ); foreach( $messages as $msg ) { $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) ); } @@ -391,57 +391,8 @@ ) . ')'; // If an edit was hidden from a page give a review link to the history } else if( self::typeAction( $row, array( 'delete', 'suppress' ), 'revision', 'deletedhistory' ) ) { - if( count($paramArray) >= 2 ) { - // Different revision types use different URL params... - $key = $paramArray[0]; - // $paramArray[1] is a CSV of the IDs - $Ids = explode( ',', $paramArray[1] ); - $query = $paramArray[1]; - $revert = array(); - // Diff link for single rev deletions - if( count($Ids) == 1 ) { - // Live revision diffs... - if( in_array( $key, array( 'oldid', 'revision' ) ) ) { - $revert[] = $this->skin->link( - $title, - $this->message['diff'], - array(), - array( - 'diff' => intval( $Ids[0] ), - 'unhide' => 1 - ), - array( 'known', 'noclasses' ) - ); - // Deleted revision diffs... - } else if( in_array( $key, array( 'artimestamp','archive' ) ) ) { - $revert[] = $this->skin->link( - SpecialPage::getTitleFor( 'Undelete' ), - $this->message['diff'], - array(), - array( - 'target' => $title->getPrefixedDBKey(), - 'diff' => 'prev', - 'timestamp' => $Ids[0] - ), - array( 'known', 'noclasses' ) - ); - } - } - // View/modify link... - $revert[] = $this->skin->link( - SpecialPage::getTitleFor( 'Revisiondelete' ), - $this->message['revdel-restore'], - array(), - array( - 'target' => $title->getPrefixedText(), - 'type' => $key, - 'ids' => $query - ), - array( 'known', 'noclasses' ) - ); - // Pipe links - $revert = wfMsg( 'parentheses', $wgLang->pipeList( $revert ) ); - } + $revert = RevisionDeleter::getLogLinks( $title, $paramArray, + $this->skin, $this->message ); // Hidden log items, give review link } else if( self::typeAction( $row, array( 'delete', 'suppress' ), 'event', 'deletedhistory' ) ) { if( count($paramArray) >= 1 ) { Property changes on: branches/wmf/1.16wmf4/includes/LogEventsList.php ___________________________________________________________________ Added: svn:mergeinfo + /branches/REL1_15/phase3/includes/LogEventsList.php:51646 /branches/sqlite/includes/LogEventsList.php:58211-58321 /branches/wmf-deployment/includes/LogEventsList.php:53381,60970 /trunk/phase3/includes/LogEventsList.php:63549,63764,63897-63901,64113,64509,65387,65391,65555,65590,65650,65816,66793 Modified: branches/wmf/1.16wmf4/includes/specials/SpecialRevisiondelete.php =================================================================== --- branches/wmf/1.16wmf4/includes/specials/SpecialRevisiondelete.php 2010-05-26 01:57:47 UTC (rev 66903) +++ branches/wmf/1.16wmf4/includes/specials/SpecialRevisiondelete.php 2010-05-26 02:07:00 UTC (rev 66904) @@ -697,6 +697,143 @@ return null; } } + + // Checks if a revision still exists in the revision table. + // If it doesn't, returns the corresponding ar_timestamp field + // so that this key can be used instead. + public static function checkRevisionExistence( $title, $revid ) { + $dbr = wfGetDB( DB_SLAVE ); + $exists = $dbr->selectField( 'revision', '1', + array( 'rev_id' => $revid ), __METHOD__ ); + + if ( $exists ) { + return true; + } + + $timestamp = $dbr->selectField( 'archive', 'ar_timestamp', + array( 'ar_namespace' => $title->getNamespace(), + 'ar_title' => $title->getDBkey(), + 'ar_rev_id' => $revid ), __METHOD__ ); + + return $timestamp; + } + + // Creates utility links for log entries. + public static function getLogLinks( $title, $paramArray, $skin, $messages ) { + global $wgLang; + + if( count($paramArray) >= 2 ) { + // Different revision types use different URL params... + $originalKey = $key = $paramArray[0]; + // $paramArray[1] is a CSV of the IDs + $Ids = explode( ',', $paramArray[1] ); + $query = $paramArray[1]; + $revert = array(); + + // For if undeleted revisions are found amidst deleted ones. + $undeletedRevisions = array(); + + // This is not going to work if some revs are deleted and some + // aren't. + if ($key == 'revision') { + foreach( $Ids as $k => $id ) { + $existResult = + self::checkRevisionExistence( $title, $id ); + + if ($existResult !== true) { + $key = 'archive'; + $Ids[$k] = $existResult; + } elseif ($key != $originalKey) { + // Undeleted revision amidst deleted ones + unset($Ids[$k]); + $undeletedRevisions[] = $id; + } + } + } + + // Diff link for single rev deletions + if( count($Ids) == 1 && !count($undeletedRevisions) ) { + // Live revision diffs... + if( in_array( $key, array( 'oldid', 'revision' ) ) ) { + $revert[] = $skin->link( + $title, + $messages['diff'], + array(), + array( + 'diff' => intval( $Ids[0] ), + 'unhide' => 1 + ), + array( 'known', 'noclasses' ) + ); + // Deleted revision diffs... + } else if( in_array( $key, array( 'artimestamp','archive' ) ) ) { + $revert[] = $skin->link( + SpecialPage::getTitleFor( 'Undelete' ), + $messages['diff'], + array(), + array( + 'target' => $title->getPrefixedDBKey(), + 'diff' => 'prev', + 'timestamp' => $Ids[0] + ), + array( 'known', 'noclasses' ) + ); + } + } + + // View/modify link... + if ( count($undeletedRevisions) ) { + // FIXME THIS IS A HORRIBLE HORRIBLE HACK AND SHOULD DIE + // It's not possible to pass a list of both deleted and + // undeleted revisions to SpecialRevisionDelete, so we're + // stuck with two links. See bug + $restoreLinks = array(); + + $restoreLinks[] = $skin->link( + SpecialPage::getTitleFor( 'Revisiondelete' ), + $messages['revdel-restore-visible'], + array(), + array( + 'target' => $title->getPrefixedText(), + 'type' => $originalKey, + 'ids' => implode(',', $undeletedRevisions), + ), + array( 'known', 'noclasses' ) + ); + + $restoreLinks[] = $skin->link( + SpecialPage::getTitleFor( 'Revisiondelete' ), + $messages['revdel-restore-deleted'], + array(), + array( + 'target' => $title->getPrefixedText(), + 'type' => $key, + 'ids' => implode(',', $Ids), + ), + array( 'known', 'noclasses' ) + ); + + $revert[] = $messages['revdel-restore'] . ' [' . + $wgLang->pipeList( $restoreLinks ) . ']'; + } else { + $revert[] = $skin->link( + SpecialPage::getTitleFor( 'Revisiondelete' ), + $messages['revdel-restore'], + array(), + array( + 'target' => $title->getPrefixedText(), + 'type' => $key, + 'ids' => implode(',', $Ids), + ), + array( 'known', 'noclasses' ) + ); + } + + // Pipe links + $revert = wfMsg( 'parentheses', $wgLang->pipeList( $revert ) ); + } + return $revert; + } } /** Property changes on: branches/wmf/1.16wmf4/includes/specials/SpecialRevisiondelete.php ___________________________________________________________________ Added: svn:mergeinfo + /branches/REL1_15/phase3/includes/specials/SpecialRevisiondelete.php:51646 /branches/sqlite/includes/specials/SpecialRevisiondelete.php:58211-58321 /branches/wmf/1.16wmf4/includes/LogEventsList.php:66793 /branches/wmf-deployment/includes/specials/SpecialRevisiondelete.php:53381,56967,60970 /trunk/phase3/includes/specials/SpecialRevisiondelete.php:63045,63047,63549,63764,63897-63901,64846,64860,64862,66793 Modified: branches/wmf/1.16wmf4/languages/messages/MessagesEn.php =================================================================== --- branches/wmf/1.16wmf4/languages/messages/MessagesEn.php 2010-05-26 01:57:47 UTC (rev 66903) +++ branches/wmf/1.16wmf4/languages/messages/MessagesEn.php 2010-05-26 02:07:00 UTC (rev 66904) @@ -1510,6 +1510,8 @@ 'logdelete-failure' => "'''Log visibility could not be set:''' $1", 'revdel-restore' => 'change visibility', +'revdel-restore-deleted' => 'deleted revisions', +'revdel-restore-visible' => 'visible revisions', 'pagehist' => 'Page history', 'deletedhist' => 'Deleted history', 'revdelete-content' => 'content', Property changes on: branches/wmf/1.16wmf4/languages/messages/MessagesEn.php ___________________________________________________________________ Modified: svn:mergeinfo - /branches/wmf/1.16wmf3/languages/messages/MessagesEn.php:64760 /branches/wmf-deployment/languages/messages/MessagesEn.php:60970 /trunk/phase3/languages/messages/MessagesEn.php:63545-63546,63549,63643,63764,63897-63901,64784,64786,64789,64800,64851,64876,65027,65112 + /branches/wmf/1.16wmf3/languages/messages/MessagesEn.php:64760 /branches/wmf-deployment/languages/messages/MessagesEn.php:60970 /trunk/phase3/languages/messages/MessagesEn.php:63545-63546,63549,63643,63764,63897-63901,64784,64786,64789,64800,64851,64876,65027,65112,66823 _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs