Merge "For consistency of the interface, don't do expensive checks on page view."
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 19 Jun 2012 06:53:07 +0000 (06:53 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 19 Jun 2012 06:53:07 +0000 (06:53 +0000)
1  2 
includes/Article.php

diff --combined includes/Article.php
@@@ -496,7 -496,7 +496,7 @@@ class Article extends Page 
                if ( $outputPage->isPrintable() ) {
                        $parserOptions->setIsPrintable( true );
                        $parserOptions->setEditSection( false );
 -              } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit' ) ) {
 +              } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user ) ) {
                        $parserOptions->setEditSection( false );
                }
  
                $user = $this->getContext()->getUser();
                $rcid = $request->getVal( 'rcid' );
  
 -              if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol' ) ) {
 +              if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol', $user ) ) {
                        return;
                }
  
                } elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI ) {
                        // Use the default message text
                        $text = $this->getTitle()->getDefaultMessageText();
+               } elseif ( $this->getTitle()->quickUserCan( 'create', $this->getContext()->getUser() )
+                       && $this->getTitle()->quickUserCan( 'edit', $this->getContext()->getUser() )
+               ) {
+                       $text = wfMsgNoTrans( 'noarticletext' );
                } else {
-                       $createErrors = $this->getTitle()->getUserPermissionsErrors( 'create', $this->getContext()->getUser() );
-                       $editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getContext()->getUser() );
-                       $errors = array_merge( $createErrors, $editErrors );
-                       if ( !count( $errors ) ) {
-                               $text = wfMsgNoTrans( 'noarticletext' );
-                       } else {
-                               $text = wfMsgNoTrans( 'noarticletext-nopermission' );
-                       }
+                       $text = wfMsgNoTrans( 'noarticletext-nopermission' );
                }
                $text = "<div class='noarticletext'>\n$text\n</div>";
  
  
                $current = ( $oldid == $this->mPage->getLatest() );
                $language = $this->getContext()->getLanguage();
 -              $td = $language->timeanddate( $timestamp, true );
 -              $tddate = $language->date( $timestamp, true );
 -              $tdtime = $language->time( $timestamp, true );
 +              $user = $this->getContext()->getUser();
 +
 +              $td = $language->userTimeAndDate( $timestamp, $user );
 +              $tddate = $language->userDate( $timestamp, $user );
 +              $tdtime = $language->userTime( $timestamp, $user );
  
                # Show user links if allowed to see them. If hidden, then show them only if requested...
                $userlinks = Linker::revUserTools( $revision, !$unhide );
                                array( 'known', 'noclasses' )
                        );
  
 -              $cdel = Linker::getRevDeleteLink( $this->getContext()->getUser(), $revision, $this->getTitle() );
 +              $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
                if ( $cdel !== '' ) {
                        $cdel .= ' ';
                }
                        $this->doDelete( $reason, $suppress );
  
                        if ( $request->getCheck( 'wpWatch' ) && $user->isLoggedIn() ) {
 -                              $this->doWatch();
 +                              WatchAction::doWatch( $title, $user );
                        } elseif ( $title->userIsWatching() ) {
 -                              $this->doUnwatch();
 +                              WatchAction::doUnwatch( $title, $user );
                        }
  
                        return;
                        }
                }
  
 -              return $this->confirmDelete( $reason );
 +              $this->confirmDelete( $reason );
        }
  
        /**