Merge "rdbms: add more ScopedCallback::newScopedIgnoreUserAbort() calls"
[lhc/web/wiklou.git] / includes / page / Article.php
index 4e28085..d8cd1c5 100644 (file)
@@ -454,7 +454,9 @@ class Article implements Page {
                $this->mRevIdFetched = $this->mRevision->getId();
                $this->fetchResult = Status::newGood( $this->mRevision );
 
-               if ( !$this->mRevision->userCan( Revision::DELETED_TEXT, $this->getContext()->getUser() ) ) {
+               if (
+                       !$this->mRevision->userCan( RevisionRecord::DELETED_TEXT, $this->getContext()->getUser() )
+               ) {
                        wfDebug( __METHOD__ . " failed to retrieve content of revision " .
                                $this->mRevision->getId() . "\n" );
 
@@ -466,7 +468,7 @@ class Article implements Page {
 
                if ( Hooks::isRegistered( 'ArticleAfterFetchContentObject' ) ) {
                        $contentObject = $this->mRevision->getContent(
-                               Revision::FOR_THIS_USER,
+                               RevisionRecord::FOR_THIS_USER,
                                $this->getContext()->getUser()
                        );
 
@@ -489,7 +491,7 @@ class Article implements Page {
 
                // For B/C only
                $this->mContentObject = $this->mRevision->getContent(
-                       Revision::FOR_THIS_USER,
+                       RevisionRecord::FOR_THIS_USER,
                        $this->getContext()->getUser()
                );
 
@@ -633,8 +635,9 @@ class Article implements Page {
                if ( $outputPage->isPrintable() ) {
                        $parserOptions->setIsPrintable( true );
                        $poOptions['enableSectionEditLinks'] = false;
-               } elseif ( $this->viewIsRenderAction
-                       || !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user )
+               } elseif ( $this->viewIsRenderAction || !$this->isCurrent() ||
+                       !MediaWikiServices::getInstance()->getPermissionManager()
+                               ->quickUserCan( 'edit', $user, $this->getTitle() )
                ) {
                        $poOptions['enableSectionEditLinks'] = false;
                }
@@ -1179,7 +1182,8 @@ class Article implements Page {
                $title = $this->getTitle();
                $rc = false;
 
-               if ( !$title->quickUserCan( 'patrol', $user )
+               if ( !MediaWikiServices::getInstance()->getPermissionManager()
+                               ->quickUserCan( 'patrol', $user, $title )
                        || !( $wgUseRCPatrol || $wgUseNPPatrol
                                || ( $wgUseFilePatrol && $title->inNamespace( NS_FILE ) ) )
                ) {
@@ -1448,6 +1452,7 @@ class Article implements Page {
 
                # Show error message
                $oldid = $this->getOldID();
+               $pm = MediaWikiServices::getInstance()->getPermissionManager();
                if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI && $title->hasSourceText() ) {
                        // use fake Content object for system message
                        $parserOptions = ParserOptions::newCanonical( 'canonical' );
@@ -1455,8 +1460,8 @@ class Article implements Page {
                } else {
                        if ( $oldid ) {
                                $text = wfMessage( 'missing-revision', $oldid )->plain();
-                       } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
-                               && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
+                       } elseif ( $pm->quickUserCan( 'create', $this->getContext()->getUser(), $title ) &&
+                               $pm->quickUserCan( 'edit', $this->getContext()->getUser(), $title )
                        ) {
                                $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
                                $text = wfMessage( $message )->plain();
@@ -1481,7 +1486,7 @@ class Article implements Page {
         * @return bool True if the view is allowed, false if not.
         */
        public function showDeletedRevisionHeader() {
-               if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
+               if ( !$this->mRevision->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
                        // Not deleted
                        return true;
                }
@@ -1489,7 +1494,7 @@ class Article implements Page {
                $outputPage = $this->getContext()->getOutput();
                $user = $this->getContext()->getUser();
                // If the user is not allowed to see it...
-               if ( !$this->mRevision->userCan( Revision::DELETED_TEXT, $user ) ) {
+               if ( !$this->mRevision->userCan( RevisionRecord::DELETED_TEXT, $user ) ) {
                        $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
                                'rev-deleted-text-permission' );
 
@@ -1499,7 +1504,7 @@ class Article implements Page {
                        # Give explanation and add a link to view the revision...
                        $oldid = intval( $this->getOldID() );
                        $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
-                       $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
+                       $msg = $this->mRevision->isDeleted( RevisionRecord::DELETED_RESTRICTED ) ?
                                'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
                        $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
                                [ $msg, $link ] );
@@ -1507,7 +1512,7 @@ class Article implements Page {
                        return false;
                // We are allowed to see...
                } else {
-                       $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
+                       $msg = $this->mRevision->isDeleted( RevisionRecord::DELETED_RESTRICTED ) ?
                                'rev-suppressed-text-view' : 'rev-deleted-text-view';
                        $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
 
@@ -2166,7 +2171,7 @@ class Article implements Page {
                return $cacheable;
        }
 
-       /**#@-*/
+       /** #@- */
 
        /**
         * Lightweight method to get the parser output for a page, checking the parser cache
@@ -2412,7 +2417,7 @@ class Article implements Page {
         * Call to WikiPage function for backwards compatibility.
         * @see WikiPage::getComment
         */
-       public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) {
+       public function getComment( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) {
                return $this->mPage->getComment( $audience, $user );
        }
 
@@ -2444,7 +2449,7 @@ class Article implements Page {
         * Call to WikiPage function for backwards compatibility.
         * @see WikiPage::getCreator
         */
-       public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) {
+       public function getCreator( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) {
                return $this->mPage->getCreator( $audience, $user );
        }
 
@@ -2556,7 +2561,7 @@ class Article implements Page {
         * Call to WikiPage function for backwards compatibility.
         * @see WikiPage::getUser
         */
-       public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
+       public function getUser( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) {
                return $this->mPage->getUser( $audience, $user );
        }
 
@@ -2564,7 +2569,7 @@ class Article implements Page {
         * Call to WikiPage function for backwards compatibility.
         * @see WikiPage::getUserText
         */
-       public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
+       public function getUserText( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) {
                return $this->mPage->getUserText( $audience, $user );
        }