(Bug 19725) Do not include suppressed edits in the "View X deleted edits" message...
authorBrian Wolff <bawolff@users.mediawiki.org>
Wed, 6 Jul 2011 16:47:29 +0000 (16:47 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Wed, 6 Jul 2011 16:47:29 +0000 (16:47 +0000)
I'm not 100% sure this is the right thing to do, see the bug for the details. But basically this doesn't include an edit in the count if its text is hidden and its hidden from admins. (Not sure if it should not be included only if everything is hidden). Its also weird to show people different things depending if they have suppress rights, without really indicating that.

Minor db note: This causes the query to no longer use a covering index. I don't think that matters but just thought i'd mention.

p.s. The upload page show deleted edits link is broken right now, (from before) I'll fix in a follow-up.

RELEASE-NOTES-1.18
includes/Skin.php
includes/SkinTemplate.php
includes/Title.php
includes/specials/SpecialUndelete.php
includes/specials/SpecialUpload.php

index 7b86b21..be122e7 100644 (file)
@@ -257,6 +257,8 @@ production.
   environments
 * (bug 14977) Fixed $wgServer detection in cases where an IPv6 address is used 
   as the server name.
+* (bug 19725) Do not list suppressed edits in the "View X deleted edits" link
+  if user cannot view suppressed edits.
 
 === API changes in 1.18 ===
 * (bug 26339) Throw warning when truncating an overlarge API result.
index 39d6a4e..d571350 100644 (file)
@@ -754,7 +754,9 @@ abstract class Skin {
 
                if ( $this->getContext()->getUser()->isAllowed( 'deletedhistory' ) &&
                        ( $this->getTitle()->getArticleId() == 0 || $action == 'history' ) ) {
-                       $n = $this->getTitle()->isDeleted();
+
+                       $includeSuppressed = $this->getContext()->getUser()->isAllowed( 'suppressrevision' );
+                       $n = $this->getTitle()->isDeleted( $includeSuppressed );
 
                        if ( $n ) {
                                if ( $this->getContext()->getUser()->isAllowed( 'undelete' ) ) {
index daa5fa1..8fef85f 100644 (file)
@@ -982,7 +982,8 @@ class SkinTemplate extends Skin {
                        } else {
                                // article doesn't exist or is deleted
                                if ( $wgUser->isAllowed( 'deletedhistory' ) ) {
-                                       $n = $title->isDeleted();
+                                       $includeSuppressed = $wgUser->isAllowed( 'suppressrevision' );
+                                       $n = $title->isDeleted( $includeSuppressed );
                                        if( $n ) {
                                                $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
                                                // If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
index 5f7c151..5dccdf9 100644 (file)
@@ -2344,20 +2344,37 @@ class Title {
        /**
         * Is there a version of this page in the deletion archive?
         *
+        * @param $includeSuppressed Boolean Include suppressed revisions?
         * @return Int the number of archived revisions
         */
-       public function isDeleted() {
+       public function isDeleted( $includeSuppressed = false ) {
                if ( $this->getNamespace() < 0 ) {
                        $n = 0;
                } else {
                        $dbr = wfGetDB( DB_SLAVE );
+                       $conditions = array( 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() );
+
+                       if( !$includeSuppressed ) {
+                               $suppressedTextBits = REVISION::DELETED_TEXT | REVISION::DELETED_RESTRICTED;
+                               $conditions[] = $dbr->bitAnd('ar_deleted', $suppressedTextBits ) .
+                               ' != ' . $suppressedTextBits;
+                       }
+
                        $n = $dbr->selectField( 'archive', 'COUNT(*)',
-                               array( 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ),
+                               $conditions,
                                __METHOD__
                        );
                        if ( $this->getNamespace() == NS_FILE ) {
-                               $n += $dbr->selectField( 'filearchive', 'COUNT(*)',
-                                       array( 'fa_name' => $this->getDBkey() ),
+                               $fconditions = array( 'fa_name' => $this->getDBkey() );
+                               if( !$includeSuppressed ) {
+                                       $suppressedTextBits = FILE::DELETED_FILE | FILE::DELETED_RESTRICTED;
+                                       $fconditions[] = $dbr->bitAnd('fa_deleted', $suppressedTextBits ) .
+                                       ' != ' . $suppressedTextBits;
+                               }
+                               
+                               $n += $dbr->selectField( 'filearchive',
+                                       'COUNT(*)',
+                                       $fconditions,
                                        __METHOD__
                                );
                        }
index 15a77c3..c11b7c0 100644 (file)
@@ -62,6 +62,7 @@ class PageArchive {
         * @return ResultWrapper
         */
        public static function listPagesByPrefix( $prefix ) {
+               global $wgUser;
                $dbr = wfGetDB( DB_SLAVE );
 
                $title = Title::newFromText( $prefix );
@@ -77,6 +78,13 @@ class PageArchive {
                        'ar_namespace' => $ns,
                        'ar_title' . $dbr->buildLike( $prefix, $dbr->anyString() ),
                );
+
+               // bug 19725
+               $suppressedText = REVISION::DELETED_TEXT | REVISION::DELETED_RESTRICTED;
+               if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+                        $conds[] = $dbr->bitAnd('ar_deleted', $suppressedText ) .
+                                ' != ' . $suppressedText;
+                }
                return self::listPages( $dbr, $conds );
        }
 
index 34653f2..159cdd6 100644 (file)
@@ -314,17 +314,20 @@ class SpecialUpload extends SpecialPage {
                $title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName );
                // Show a subtitle link to deleted revisions (to sysops et al only)
                if( $title instanceof Title ) {
-                       $count = $title->isDeleted();
-                       if ( $count > 0 && $wgUser->isAllowed( 'deletedhistory' ) ) {
-                               $link = wfMsgExt(
-                                       $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted',
-                                       array( 'parse', 'replaceafter' ),
-                                       $this->getSkin()->linkKnown(
-                                               SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedText() ),
-                                               wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $count )
-                                       )
-                               );
-                               $wgOut->addHTML( "<div id=\"contentSub2\">{$link}</div>" );
+                       if ( $wgUser->isAllowed( 'deletedhistory' ) ) {
+                               $canViewSuppress = $wgUser->isAllowed( 'suppressrevision' );
+                               $count = $title->isDeleted( $canViewSuppress );
+                               if ( $count > 0 ) {
+                                       $link = wfMsgExt(
+                                               $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted',
+                                               array( 'parse', 'replaceafter' ),
+                                               $this->getSkin()->linkKnown(
+                                                       SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedText() ),
+                                                       wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $count )
+                                               )
+                                       );
+                                       $wgOut->addHTML( "<div id=\"contentSub2\">{$link}</div>" );
+                               }
                        }
                }