r101672 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101671‎ | r101672 | r101673 >
Date:20:18, 2 November 2011
Author:ialex
Status:ok
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -385,6 +385,13 @@
386386 wfProfileIn( __METHOD__ );
387387 wfDebug( __METHOD__.": enter\n" );
388388
 389+ // If they used redlink=1 and the page exists, redirect to the main article
 390+ if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) {
 391+ $wgOut->redirect( $this->mTitle->getFullURL() );
 392+ wfProfileOut( __METHOD__ );
 393+ return;
 394+ }
 395+
389396 $this->importFormData( $wgRequest );
390397 $this->firsttime = false;
391398
@@ -419,28 +426,23 @@
420427 $this->readOnlyPage( $content, true, $permErrors, 'edit' );
421428 wfProfileOut( __METHOD__ );
422429 return;
423 - } else {
424 - if ( $this->save ) {
425 - $this->formtype = 'save';
426 - } elseif ( $this->preview ) {
 430+ }
 431+
 432+ if ( $this->save ) {
 433+ $this->formtype = 'save';
 434+ } elseif ( $this->preview ) {
 435+ $this->formtype = 'preview';
 436+ } elseif ( $this->diff ) {
 437+ $this->formtype = 'diff';
 438+ } else { # First time through
 439+ $this->firsttime = true;
 440+ if ( $this->previewOnOpen() ) {
427441 $this->formtype = 'preview';
428 - } elseif ( $this->diff ) {
429 - $this->formtype = 'diff';
430 - } else { # First time through
431 - $this->firsttime = true;
432 - if ( $this->previewOnOpen() ) {
433 - $this->formtype = 'preview';
434 - } else {
435 - $this->formtype = 'initial';
436 - }
 442+ } else {
 443+ $this->formtype = 'initial';
437444 }
438445 }
439446
440 - // If they used redlink=1 and the page exists, redirect to the main article
441 - if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) {
442 - $wgOut->redirect( $this->mTitle->getFullURL() );
443 - }
444 -
445447 wfProfileIn( __METHOD__."-business-end" );
446448
447449 $this->isConflict = false;

Status & tagging log