From: Alexandre Emsenhuber Date: Thu, 21 Feb 2013 13:44:53 +0000 (+0100) Subject: Put the check for empty comment outside of the section anchor section of EditPage... X-Git-Tag: 1.31.0-rc.0~20563^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=71b257c66ddfe50e984b95af68481cadc382c825;p=lhc%2Fweb%2Fwiklou.git Put the check for empty comment outside of the section anchor section of EditPage::internalAttemptSave() Also reorganise checks for better clarity Change-Id: Ib75b2c0b0c240459d58618eed283b547aaefd7f6 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 5434dabd4f..8a3d630e85 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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