(Bug 15936) New page's patrol button should always be visible
[lhc/web/wiklou.git] / includes / Article.php
index 5bd3488..8058ead 100644 (file)
@@ -218,7 +218,7 @@ class Article {
                                if( wfEmptyMsg( $message, $text ) )
                                        $text = '';
                        } else {
-                               $text = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
+                               $text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' );
                        }
                        wfProfileOut( __METHOD__ );
                        return $text;
@@ -228,6 +228,21 @@ class Article {
                        return $this->mContent;
                }
        }
+       
+       /**
+        * Get the text of the current revision. No side-effects...
+        *
+        * @return Return the text of the current revision
+       */
+       public function getRawText() {
+               // Check process cache for current revision
+               if( $this->mContentLoaded && $this->mOldId == 0 ) {
+                       return $this->mContent;
+               }
+               $rev = Revision::newFromTitle( $this->mTitle );
+               $text = $rev ? $rev->getRawText() : false;
+               return $text;
+       }
 
        /**
         * This function returns the text of a section, specified by a number ($section).
@@ -765,6 +780,16 @@ class Article {
                        wfProfileOut( __METHOD__ );
                        return;
                }
+               
+               if( $ns == NS_USER || $ns == NS_USER_TALK ) {
+                       # User/User_talk subpages are not modified. (bug 11443)
+                       if( !$this->mTitle->isSubpage() ) {
+                               $block = new Block();
+                               if( $block->load( $this->mTitle->getBaseText() ) ) {
+                                       $wgOut->setRobotpolicy( 'noindex,nofollow' );
+                               }
+                       }
+               }
 
                # Should the parser cache be used?
                $pcache = $this->useParserCache( $oldid );
@@ -816,14 +841,16 @@ class Article {
                                $this->showDeletionLog();
                        }
                        $text = $this->getContent();
-                       if( $text === false ) {
+                       // For now, check also for ID until getContent actually returns
+                       // false for pages that do not exists
+                       if( $text === false || $this->getID() === 0 ) {
                                # Failed to load, replace text with error message
                                $t = $this->mTitle->getPrefixedText();
                                if( $oldid ) {
-                                       $d = wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid );
-                                       $text = wfMsg( 'missing-article', $t, $d );
+                                       $d = wfMsgExt( 'missingarticle-rev', 'escape', $oldid );
+                                       $text = wfMsgExt( 'missing-article', 'parsemag', $t, $d );
                                } else {
-                                       $text = wfMsg( 'noarticletext' );
+                                       $text = wfMsgExt( 'noarticletext', 'parsemag' );
                                }
                        }
                        
@@ -836,7 +863,7 @@ class Article {
                                        // for better machine handling of broken links.
                                        $return404 = true;
                                }
-                       } 
+                       }
 
                        if( $return404 ) {
                                $wgRequest->response()->header( "HTTP/1.x 404 Not Found" );
@@ -940,6 +967,13 @@ class Article {
                        $wgOut->addWikiMsg('anontalkpagetext');
                }
 
+               # Only diffs and new page links from RC give rcid params, so if
+               # we are just viewing the page normally with no rcid, try to find it. 
+               # This is more convenient for users.
+               if( empty($rcid) && $this->mTitle->userCan('patrol') ) {
+                       $firstRev = $this->mTitle->getFirstRevision();
+                       $rcid = $firstRev->isUnpatrolled();
+               }
                # If we have been passed an &rcid= parameter, we want to give the user a
                # chance to mark this new article as patrolled.
                if( !empty($rcid) && $this->mTitle->exists() && $this->mTitle->userCan('patrol') ) {
@@ -1128,7 +1162,7 @@ class Article {
                        if( $this->getID() == 0 ) {
                                $text = false;
                        } else {
-                               $text = $this->getContent();
+                               $text = $this->getRawText();
                        }
                        $wgMessageCache->replace( $this->mTitle->getDBkey(), $text );
                }
@@ -1490,7 +1524,7 @@ class Article {
                $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed('minoredit');
                $bot = $flags & EDIT_FORCE_BOT;
 
-               $oldtext = $this->getContent();
+               $oldtext = $this->getRawText(); // current revision
                $oldsize = strlen( $oldtext );
 
                # Provide autosummaries if one is not provided and autosummaries are enabled.
@@ -2398,7 +2432,7 @@ class Article {
                        return false;
                }
 
-               $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getContent() ), -1 );
+               $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getRawText() ), -1 );
                array_push( $wgDeferredUpdateList, $u );
 
                // Bitfields to further suppress the content