* Fix WebRequest.php
[lhc/web/wiklou.git] / includes / Article.php
index ad45b44..d6809bf 100644 (file)
@@ -859,7 +859,7 @@ class Article {
                                }
                        } else if ( $rt = Title::newFromRedirect( $text ) ) {
                                # Don't append the subtitle if this was an old revision
-                               $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() );
+                               $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
                                $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser));
                                $wgOut->addParserOutputNoText( $parseout );
                        } else if ( $pcache ) {
@@ -934,7 +934,13 @@ class Article {
                        && !$this->mTitle->isCssJsSubpage();
        }
        
-       protected function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
+       /**
+        * View redirect
+        * @param Title $target Title of destination to redirect
+        * @param Bool  $appendSubtitle Object[optional]
+        * @param Bool  $forceKnown Should the image be shown as a bluelink regardless of existence?
+        */
+       public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
                global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
                
                # Display redirect
@@ -950,8 +956,8 @@ class Article {
                else
                        $link = $sk->makeLinkObj( $target, htmlspecialchars( $target->getFullText() ) );
 
-               $wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
-                       '<span class="redirectText">'.$link.'</span>' );
+               return '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
+                       '<span class="redirectText">'.$link.'</span>';
                
        }
 
@@ -1823,7 +1829,6 @@ class Article {
 
                # If nothing's changed, do nothing
                if( $changed ) {
-                       global $wgGroupPermissions;
                        if( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) {
 
                                $dbw = wfGetDB( DB_MASTER );
@@ -1885,6 +1890,7 @@ class Article {
                                $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true );
                                $nullRevId = $nullRevision->insertOn( $dbw );
 
+                               $latest = $this->getLatest();
                                # Update page record
                                $dbw->update( 'page',
                                        array( /* SET */
@@ -1896,7 +1902,7 @@ class Article {
                                        ), 'Article::protect'
                                );
                                
-                               wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) );
+                               wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, $latest) );
                                wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) );
 
                                # Update the protection log
@@ -1977,7 +1983,7 @@ class Article {
                $row = $dbw->fetchObject($res);
                $onlyAuthor = $row->rev_user_text;
                // Try to find a second contributor
-               while( $row = $dbw->fetchObject($res) ) {
+               foreach( $res as $row ) {
                        if($row->rev_user_text != $onlyAuthor) {
                                $onlyAuthor = false;
                                break;
@@ -3281,11 +3287,9 @@ class Article {
                        array( 'tl_namespace', 'tl_title' ),
                        array( 'tl_from' => $id ),
                        __METHOD__ );
-               if ( false !== $res ) {
-                       if ( $dbr->numRows( $res ) ) {
-                               while ( $row = $dbr->fetchObject( $res ) ) {
-                                       $result[] = Title::makeTitle( $row->tl_namespace, $row->tl_title );
-                               }
+               if( false !== $res ) {
+                       foreach( $res as $row ) {
+                               $result[] = Title::makeTitle( $row->tl_namespace, $row->tl_title );
                        }
                }
                $dbr->freeResult( $res );
@@ -3312,10 +3316,8 @@ class Article {
                                'page_namespace' => NS_CATEGORY, 'page_title=cl_to'),
                        __METHOD__ );
                if ( false !== $res ) {
-                       if ( $dbr->numRows( $res ) ) {
-                               while ( $row = $dbr->fetchObject( $res ) ) {
-                                       $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to );
-                               }
+                       foreach( $res as $row ) {
+                               $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to );
                        }
                }
                $dbr->freeResult( $res );
@@ -3413,10 +3415,8 @@ class Article {
                        global $wgContLang;
 
                        if ( false !== $res ) {
-                               if ( $dbr->numRows( $res ) ) {
-                                       while ( $row = $dbr->fetchObject( $res ) ) {
-                                               $tlTemplates[] = $wgContLang->getNsText( $row->tl_namespace ) . ':' . $row->tl_title ;
-                                       }
+                               foreach( $res as $row ) {
+                                       $tlTemplates[] = $wgContLang->getNsText( $row->tl_namespace ) . ':' . $row->tl_title ;
                                }
                        }