SECURITY: RevDel: Check all revisions for suppression, not just the first
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 9 Apr 2015 17:59:16 +0000 (13:59 -0400)
committerChad Horohoe <chadh@wikimedia.org>
Fri, 16 Oct 2015 21:11:20 +0000 (14:11 -0700)
If any of the revisions in the list are deleted, do not allow changing
the permissions without suppressrevision.

Bug: T95589
Change-Id: Ia8a3ef13b73925d14a79775a50d46b939c01664f

includes/revisiondelete/RevDelList.php
includes/specials/SpecialRevisiondelete.php

index 7aac3b8..7ffb427 100644 (file)
@@ -73,6 +73,25 @@ abstract class RevDelList extends RevisionListBase {
                return $target;
        }
 
+       /**
+        * Indicate whether any item in this list is suppressed
+        * @since 1.25
+        * @return bool
+        */
+       public function areAnySuppressed() {
+               $bit = $this->getSuppressBit();
+
+               // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
+               for ( $this->reset(); $this->current(); $this->next() ) {
+                       // @codingStandardsIgnoreEnd
+                       $item = $this->current();
+                       if ( $item->getBits() & $bit ) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
        /**
         * Set the visibility for the revisions in this list. Logging and
         * transactions are done here.
index c98aa46..65cb8e5 100644 (file)
@@ -170,11 +170,10 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $this->typeLabels = self::$UILabels[$this->typeName];
                $list = $this->getList();
                $list->reset();
-               $bitfield = $list->current()->getBits();
                $this->mIsAllowed = $user->isAllowed( RevisionDeleter::getRestriction( $this->typeName ) );
                $canViewSuppressedOnly = $this->getUser()->isAllowed( 'viewsuppressed' ) &&
                        !$this->getUser()->isAllowed( 'suppressrevision' );
-               $pageIsSuppressed = $bitfield & Revision::DELETED_RESTRICTED;
+               $pageIsSuppressed = $list->areAnySuppressed();
                $this->mIsAllowed = $this->mIsAllowed && !( $canViewSuppressedOnly && $pageIsSuppressed );
 
                $this->otherReason = $request->getVal( 'wpReason' );