From a53d9327a836ffe9d94122a4bc8f7fe21be75adf Mon Sep 17 00:00:00 2001 From: Jackmcbarn Date: Tue, 26 Nov 2013 17:46:42 -0500 Subject: [PATCH] Show minor edits and tags in Special:Undelete Show minor edit marks and change tags when viewing deleted history and diffs in Special:Undelete, in the same way that minor edits and tags are seen for non-deleted history and diffs. Bug: 57510 Change-Id: I99e81b8255c663df2679e3b31a693c12745878c3 --- includes/ChangeTags.php | 12 +++--- includes/specials/SpecialUndelete.php | 57 +++++++++++++++++++++++---- languages/messages/MessagesEn.php | 2 +- languages/messages/MessagesQqq.php | 8 ++-- maintenance/language/messageTypes.inc | 2 +- maintenance/language/messages.inc | 2 +- 6 files changed, 64 insertions(+), 19 deletions(-) diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php index fd94bea31a..53f2955d44 100644 --- a/includes/ChangeTags.php +++ b/includes/ChangeTags.php @@ -184,17 +184,19 @@ class ChangeTags { // Figure out which conditions can be done. if ( in_array( 'recentchanges', $tables ) ) { - $join_cond = 'rc_id'; + $join_cond = 'ct_rc_id=rc_id'; } elseif ( in_array( 'logging', $tables ) ) { - $join_cond = 'log_id'; + $join_cond = 'ct_log_id=log_id'; } elseif ( in_array( 'revision', $tables ) ) { - $join_cond = 'rev_id'; + $join_cond = 'ct_rev_id=rev_id'; + } elseif ( in_array( 'archive', $tables ) ) { + $join_cond = 'ct_rev_id=ar_rev_id'; } else { throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' ); } $fields['ts_tags'] = wfGetDB( DB_SLAVE )->buildGroupConcatField( - ',', 'change_tag', 'ct_tag', "ct_$join_cond=$join_cond" + ',', 'change_tag', 'ct_tag', $join_cond ); if ( $wgUseTagFilter && $filter_tag ) { @@ -202,7 +204,7 @@ class ChangeTags { // Add an INNER JOIN on change_tag $tables[] = 'change_tag'; - $join_conds['change_tag'] = array( 'INNER JOIN', "ct_$join_cond=$join_cond" ); + $join_conds['change_tag'] = array( 'INNER JOIN', $join_cond ); $conds['ct_tag'] = $filter_tag; } } diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index d4aed113bf..d33851d18d 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -124,6 +124,8 @@ class PageArchive { $dbr = wfGetDB( DB_SLAVE ); + $tables = array( 'archive' ); + $fields = array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1', @@ -134,12 +136,28 @@ class PageArchive { $fields[] = 'ar_content_model'; } - $res = $dbr->select( 'archive', + $conds = array( 'ar_namespace' => $this->title->getNamespace(), + 'ar_title' => $this->title->getDBkey() ); + + $options = array( 'ORDER BY' => 'ar_timestamp DESC' ); + + $join_conds = array(); + + ChangeTags::modifyDisplayQuery( + $tables, $fields, - array( 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDBkey() ), + $conds, + $join_conds, + $options + ); + + $res = $dbr->select( $tables, + $fields, + $conds, __METHOD__, - array( 'ORDER BY' => 'ar_timestamp DESC' ) ); + $options, + $join_conds + ); return $dbr->resultObject( $res ); } @@ -1083,6 +1101,16 @@ class SpecialUndelete extends SpecialPage { $rdel = " $rdel"; } + $minor = $rev->isMinor() ? ChangesList::flag( 'minor' ) : ''; + + $tags = wfGetDB( DB_SLAVE )->selectField( + 'tag_summary', + 'ts_tags', + array( 'ts_rev_id' => $rev->getId() ), + __METHOD__ + ); + $tagSummary = ChangeTags::formatSummaryRow( $tags, 'deleteddiff' ); + return '
' . Linker::link( $targetPage, @@ -1100,7 +1128,10 @@ class SpecialUndelete extends SpecialPage { Linker::revUserTools( $rev ) . '
' . '
' . '
' . - Linker::revComment( $rev ) . $rdel . '
' . + $minor . Linker::revComment( $rev ) . $rdel . '
' . + '
' . + '
' . + $tagSummary[0] . '
' . '
'; } @@ -1367,6 +1398,9 @@ class SpecialUndelete extends SpecialPage { // User links $userLink = Linker::revUserTools( $rev ); + // Minor edit + $minor = $rev->isMinor() ? ChangesList::flag( 'minor' ) : ''; + // Revision text size $size = $row->ar_len; if ( !is_null( $size ) ) { @@ -1376,14 +1410,21 @@ class SpecialUndelete extends SpecialPage { // Edit summary $comment = Linker::revComment( $rev ); + // Tags + $attribs = array(); + list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'deletedhistory' ); + if ( $classes ) { + $attribs['class'] = implode( ' ', $classes ); + } + // Revision delete links $revdlink = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj ); - $revisionRow = $this->msg( 'undelete-revisionrow' ) - ->rawParams( $checkBox, $revdlink, $last, $pageLink, $userLink, $revTextSize, $comment ) + $revisionRow = $this->msg( 'undelete-revision-row' ) + ->rawParams( $checkBox, $revdlink, $last, $pageLink, $userLink, $minor, $revTextSize, $comment, $tagSummary ) ->escaped(); - return "
  • $revisionRow
  • "; + return Xml::tags( 'li', $attribs, $revisionRow ) . "\n"; } private function formatFileRow( $row ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 5b48e7ddd8..c1cf10f7b7 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3225,7 +3225,7 @@ It may have already been undeleted.', $1', 'undelete-show-file-confirm' => 'Are you sure you want to view the deleted revision of the file "$1" from $2 at $3?', 'undelete-show-file-submit' => 'Yes', -'undelete-revisionrow' => '$1 $2 ($3) $4 . . $5 $6 $7', # only translate this message to other languages if you have to change it +'undelete-revision-row' => '$1 $2 ($3) $4 . . $5 $6 $7 $8 $9', # only translate this message to other languages if you have to change it # Namespace form on various pages 'namespace' => 'Namespace:', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 755ccbef66..4d84a950f8 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -6014,15 +6014,17 @@ Parameters: * $3 - the time of the displayed revision {{Identical|Are you sure you want to view the deleted revision of the file...}}', 'undelete-show-file-submit' => '{{Identical|Yes}}', -'undelete-revisionrow' => "{{Optional}} +'undelete-revision-row' => "{{Optional}} A revision row in the undelete page. Parameters: * $1 is a checkBox to indicate whether to restore this specific revision * $2 is a link to the revision * $3 is a link to the last revision of a page ({{msg-mw|last}}) * $4 is a link to the page * $5 is a link to the revision's user -* $6 is the revision size -* $7 is the revision comment", +* $6 is the revision's minor edit identifier +* $7 is the revision size +* $8 is the revision comment +* $9 is the revision's tags", # Namespace form on various pages 'namespace' => 'This message is located at [[Special:Contributions]]. diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index 7a10b66077..b06c11f61d 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -477,7 +477,7 @@ $wgOptionalMessages = array( 'version-entrypoints-scriptpath', 'mergehistory-revisionrow', 'categoryviewer-pagedlinks', - 'undelete-revisionrow', + 'undelete-revision-row', 'pageinfo-redirects-value', 'created', // @deprecated. Remove in MediaWiki 1.23. 'changed', // @deprecated. Remove in MediaWiki 1.23. diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 045126336c..f0160ccc92 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2207,7 +2207,7 @@ $wgMessageStructure = array( 'undelete-error-long', 'undelete-show-file-confirm', 'undelete-show-file-submit', - 'undelete-revisionrow', + 'undelete-revision-row', ), 'nsform' => array( 'namespace', -- 2.20.1