Put the check for empty comment outside of the section anchor section of EditPage...
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 21 Feb 2013 13:44:53 +0000 (14:44 +0100)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 21 Feb 2013 13:44:53 +0000 (14:44 +0100)
Also reorganise checks for better clarity

Change-Id: Ib75b2c0b0c240459d58618eed283b547aaefd7f6

includes/EditPage.php

index 5434dab..8a3d630 100644 (file)
@@ -1561,43 +1561,40 @@ class EditPage {
                                return $status;
                        }
 
-                       # Handle the user preference to force summaries here, but not for null edits
-                       if ( $this->section != 'new' && !$this->allowBlankSummary
-                               && !$content->equals( $this->getOriginalContent() )
-                               && !$content->isRedirect() ) # check if it's not a redirect
-                       {
-                               if ( md5( $this->summary ) == $this->autoSumm ) {
+                       if ( $this->section == 'new' ) {
+                               // Handle the user preference to force summaries here
+                               if ( !$this->allowBlankSummary && trim( $this->summary ) == '' ) {
                                        $this->missingSummary = true;
-                                       $status->fatal( 'missingsummary' );
+                                       $status->fatal( 'missingsummary' ); // or 'missingcommentheader' if $section == 'new'. Blegh
                                        $status->value = self::AS_SUMMARY_NEEDED;
                                        wfProfileOut( __METHOD__ );
                                        return $status;
                                }
-                       }
 
-                       # And a similar thing for new sections
-                       if ( $this->section == 'new' && !$this->allowBlankSummary ) {
-                               if ( trim( $this->summary ) == '' ) {
-                                       $this->missingSummary = true;
-                                       $status->fatal( 'missingsummary' ); // or 'missingcommentheader' if $section == 'new'. Blegh
-                                       $status->value = self::AS_SUMMARY_NEEDED;
+                               // Do not allow the user to post an empty comment
+                               if ( $this->textbox1 == '' ) {
+                                       $this->missingComment = true;
+                                       $status->fatal( 'missingcommenttext' );
+                                       $status->value = self::AS_TEXTBOX_EMPTY;
                                        wfProfileOut( __METHOD__ );
                                        return $status;
                                }
+                       } elseif ( !$this->allowBlankSummary
+                               && !$content->equals( $this->getOriginalContent() )
+                               && !$content->isRedirect()
+                               && md5( $this->summary ) == $this->autoSumm
+                       ) {
+                               $this->missingSummary = true;
+                               $status->fatal( 'missingsummary' );
+                               $status->value = self::AS_SUMMARY_NEEDED;
+                               wfProfileOut( __METHOD__ );
+                               return $status;
                        }
 
                        # All's well
                        wfProfileIn( __METHOD__ . '-sectionanchor' );
                        $sectionanchor = '';
                        if ( $this->section == 'new' ) {
-                               if ( $this->textbox1 == '' ) {
-                                       $this->missingComment = true;
-                                       $status->fatal( 'missingcommenttext' );
-                                       $status->value = self::AS_TEXTBOX_EMPTY;
-                                       wfProfileOut( __METHOD__ . '-sectionanchor' );
-                                       wfProfileOut( __METHOD__ );
-                                       return $status;
-                               }
                                if ( $this->sectiontitle !== '' ) {
                                        $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
                                        // If no edit summary was specified, create one automatically from the section