From bf2dc3d5acefb4eb4a2bc26f707bd0327e6f46c7 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 2 Nov 2011 20:18:43 +0000 Subject: [PATCH] Early return if the page exists and redlink parameter was provided instead of going through all the normal process and then redirect; also moved a part of outside the "else" condition for consistency with the code below --- includes/EditPage.php | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 1696b26a6a..43a14d92b2 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -385,6 +385,13 @@ class EditPage { wfProfileIn( __METHOD__ ); wfDebug( __METHOD__.": enter\n" ); + // If they used redlink=1 and the page exists, redirect to the main article + if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) { + $wgOut->redirect( $this->mTitle->getFullURL() ); + wfProfileOut( __METHOD__ ); + return; + } + $this->importFormData( $wgRequest ); $this->firsttime = false; @@ -419,28 +426,23 @@ class EditPage { $this->readOnlyPage( $content, true, $permErrors, 'edit' ); wfProfileOut( __METHOD__ ); return; - } else { - if ( $this->save ) { - $this->formtype = 'save'; - } elseif ( $this->preview ) { + } + + if ( $this->save ) { + $this->formtype = 'save'; + } elseif ( $this->preview ) { + $this->formtype = 'preview'; + } elseif ( $this->diff ) { + $this->formtype = 'diff'; + } else { # First time through + $this->firsttime = true; + if ( $this->previewOnOpen() ) { $this->formtype = 'preview'; - } elseif ( $this->diff ) { - $this->formtype = 'diff'; - } else { # First time through - $this->firsttime = true; - if ( $this->previewOnOpen() ) { - $this->formtype = 'preview'; - } else { - $this->formtype = 'initial'; - } + } else { + $this->formtype = 'initial'; } } - // If they used redlink=1 and the page exists, redirect to the main article - if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) { - $wgOut->redirect( $this->mTitle->getFullURL() ); - } - wfProfileIn( __METHOD__."-business-end" ); $this->isConflict = false; -- 2.20.1