Disable the unsafe redirect default on Article::getContent(). A couple
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 30 Apr 2004 08:19:59 +0000 (08:19 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 30 Apr 2004 08:19:59 +0000 (08:19 +0000)
tweaks seem to fix editing of redirects problem.

Also split up some instances of "?>" in regexp strings. PHP itself doesn't
seem to break off the code there, but it's not really recommended (and
it confuses the hell out of my editor, breaking syntax highlighting
and jumping to functions).

includes/Article.php
includes/EditPage.php

index f9d076d..158e1dc 100644 (file)
@@ -62,7 +62,7 @@ class Article {
        # not told otherwise, and so may cause a change to mTitle.
 
        # Return the text of this revision
-       function getContent( $noredir = false )
+       function getContent( $noredir )
        {
                global $wgRequest;
 
@@ -111,7 +111,7 @@ class Article {
                                                # split it up by section
                                                $secs =
                                                  preg_split(
-                                                 "/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
+                                                 "/(^=+.*?=+|^<h[1-6].*?" . ">.*?<\/h[1-6].*?" . ">)/mi",
                                                  $striptext, -1,
                                                  PREG_SPLIT_DELIM_CAPTURE);
 
@@ -483,7 +483,7 @@ class Article {
                        }
                }
 
-               $text = $this->getContent(); # May change mTitle
+               $text = $this->getContent( false ); # May change mTitle by following a redirect
                $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
 
                # We're looking at an old revision
@@ -586,7 +586,7 @@ class Article {
        /* Side effects: loads last edit */
        function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = ""){
                $this->loadLastEdit();
-               $oldtext = $this->getContent();
+               $oldtext = $this->getContent( true );
                if ($section != "") {
                        if($section=="new") {
                                if($summary) $subject="== {$summary} ==\n\n";
@@ -602,7 +602,7 @@ class Article {
 
                                # now that we can be sure that no pseudo-sections are in the source,
                                # split it up
-                               $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
+                               $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?" . ">.*?<\/h[1-6].*?" . ">)/mi",
                                  $oldtext,-1,PREG_SPLIT_DELIM_CAPTURE);
                                $secs[$section*2]=$text."\n\n"; // replace with edited
                                if($section) { $secs[$section*2-1]=""; } // erase old headline
@@ -1197,7 +1197,7 @@ class Article {
                        return;
                }
                if ( wfReadOnly() ) {
-                       $wgOut->readOnlyPage( $this->getContent() );
+                       $wgOut->readOnlyPage( $this->getContent( true ) );
                        return;
                }
                
index 52f4093..f41ce5c 100644 (file)
@@ -33,7 +33,7 @@ class EditPage {
                $this->importFormData( $wgRequest );
 
                if ( ! $this->mTitle->userCanEdit() ) {
-                       $wgOut->readOnlyPage( $this->mArticle->getContent(), true );
+                       $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
                        return;
                }
                if ( $wgUser->isBlocked() ) {
@@ -48,7 +48,7 @@ class EditPage {
                        if( $this->save || $this->preview ) {
                                $this->editForm( "preview" );
                        } else {
-                               $wgOut->readOnlyPage( $this->mArticle->getContent() );
+                               $wgOut->readOnlyPage( $this->mArticle->getContent( true ) );
                        }
                        return;
                }
@@ -194,7 +194,7 @@ class EditPage {
 
                if ( "initial" == $formtype ) {
                        $this->edittime = $this->mArticle->getTimestamp();
-                       $this->textbox1 = $this->mArticle->getContent(true);
+                       $this->textbox1 = $this->mArticle->getContent( true );
                        $this->summary = "";
                        $this->proxyCheck();
                }
@@ -209,7 +209,7 @@ class EditPage {
                        $wgOut->addHTML( wfMsg( "explainconflict" ) );
 
                        $this->textbox2 = $this->textbox1;
-                       $this->textbox1 = $this->mArticle->getContent(true);
+                       $this->textbox1 = $this->mArticle->getContent( true );
                        $this->edittime = $this->mArticle->getTimestamp();
                } else {
                        $s = wfMsg( "editing", $this->mTitle->getPrefixedText() );