Show minor edits and tags in Special:Undelete
authorJackmcbarn <jackmcbarn@gmail.com>
Tue, 26 Nov 2013 22:46:42 +0000 (17:46 -0500)
committerJackmcbarn <jackmcbarn@gmail.com>
Wed, 27 Nov 2013 17:50:52 +0000 (12:50 -0500)
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
includes/specials/SpecialUndelete.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messageTypes.inc
maintenance/language/messages.inc

index fd94bea..53f2955 100644 (file)
@@ -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;
                }
        }
index d4aed11..d33851d 100644 (file)
@@ -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 '<div id="mw-diff-' . $prefix . 'title1"><strong>' .
                        Linker::link(
                                $targetPage,
@@ -1100,7 +1128,10 @@ class SpecialUndelete extends SpecialPage {
                        Linker::revUserTools( $rev ) . '<br />' .
                        '</div>' .
                        '<div id="mw-diff-' . $prefix . 'title3">' .
-                       Linker::revComment( $rev ) . $rdel . '<br />' .
+                       $minor . Linker::revComment( $rev ) . $rdel . '<br />' .
+                       '</div>' .
+                       '<div id="mw-diff-' . $prefix . 'title5">' .
+                       $tagSummary[0] . '<br />' .
                        '</div>';
        }
 
@@ -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 "<li>$revisionRow</li>";
+               return Xml::tags( 'li', $attribs, $revisionRow ) . "\n";
        }
 
        private function formatFileRow( $row ) {
index 5b48e7d..c1cf10f 100644 (file)
@@ -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 "<nowiki>$1</nowiki>" 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:',
index 755ccbe..4d84a95 100644 (file)
@@ -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]].
index 7a10b66..b06c11f 100644 (file)
@@ -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.
index 0451263..f0160cc 100644 (file)
@@ -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',