filebackend: Convert trigger_error to PSR log warning
[lhc/web/wiklou.git] / includes / Revision / RevisionRecord.php
index 70a891c..cf35371 100644 (file)
@@ -59,7 +59,7 @@ abstract class RevisionRecord {
        const FOR_THIS_USER = 2;
        const RAW = 3;
 
-       /** @var string Wiki ID; false means the current wiki */
+       /** @var string|false Wiki ID; false means the current wiki */
        protected $mWiki = false;
        /** @var int|null */
        protected $mId;
@@ -82,7 +82,7 @@ abstract class RevisionRecord {
        /** @var CommentStoreComment|null */
        protected $mComment;
 
-       /**  @var Title */
+       /** @var Title */
        protected $mTitle; // TODO: we only need the title for permission checks!
 
        /** @var RevisionSlots */
@@ -94,17 +94,16 @@ abstract class RevisionRecord {
         *
         * @param Title $title The title of the page this Revision is associated with.
         * @param RevisionSlots $slots The slots of this revision.
-        * @param bool|string $wikiId the wiki ID of the site this Revision belongs to,
-        *        or false for the local site.
+        * @param bool|string $dbDomain DB domain of the relevant wiki or false for the current one.
         *
         * @throws MWException
         */
-       function __construct( Title $title, RevisionSlots $slots, $wikiId = false ) {
-               Assert::parameterType( 'string|boolean', $wikiId, '$wikiId' );
+       function __construct( Title $title, RevisionSlots $slots, $dbDomain = false ) {
+               Assert::parameterType( 'string|boolean', $dbDomain, '$dbDomain' );
 
                $this->mTitle = $title;
                $this->mSlots = $slots;
-               $this->mWiki = $wikiId;
+               $this->mWiki = $dbDomain;
 
                // XXX: this is a sensible default, but we may not have a Title object here in the future.
                $this->mPageId = $title->getArticleID();
@@ -515,16 +514,23 @@ abstract class RevisionRecord {
                        } else {
                                $permissions = [ 'deletedhistory' ];
                        }
+
+                       // XXX: How can we avoid global scope here?
+                       //      Perhaps the audience check should be done in a callback.
+                       $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
                        $permissionlist = implode( ', ', $permissions );
                        if ( $title === null ) {
                                wfDebug( "Checking for $permissionlist due to $field match on $bitfield\n" );
-                               return $user->isAllowedAny( ...$permissions );
+                               foreach ( $permissions as $perm ) {
+                                       if ( $permissionManager->userHasRight( $user, $perm ) ) {
+                                               return true;
+                                       }
+                               }
+                               return false;
                        } else {
                                $text = $title->getPrefixedText();
                                wfDebug( "Checking for $permissionlist on $text due to $field match on $bitfield\n" );
 
-                               $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
-
                                foreach ( $permissions as $perm ) {
                                        if ( $permissionManager->userCan( $perm, $user, $title ) ) {
                                                return true;