Actually detect duplicate section=new submissions
The current check will basically never pass, since it's looking for the submitted section title to match the section title inserted into the 'newsectionsummary' message. So let's factor out the code for applying 'newsectionsummary' and use that for the conflict check. We can't just update $this->summary earlier, since later checks depend on looking at the submitted summary rather than the mangled one. Bug: 67634 Change-Id: I72890c0641f991696ec98b50a6a42b2be7f46f63
This commit is contained in:
parent
a574a40dc5
commit
355cbd2e3e
1 changed files with 35 additions and 40 deletions
|
|
@ -1523,6 +1523,37 @@ class EditPage {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the summary to be used for a new section.
|
||||
*
|
||||
* @param string $sectionanchor Set to the section anchor text
|
||||
* @return string
|
||||
*/
|
||||
private function newSectionSummary( &$sectionanchor = null ) {
|
||||
global $wgParser;
|
||||
|
||||
if ( $this->sectiontitle !== '' ) {
|
||||
$sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
|
||||
// If no edit summary was specified, create one automatically from the section
|
||||
// title and have it link to the new section. Otherwise, respect the summary as
|
||||
// passed.
|
||||
if ( $this->summary === '' ) {
|
||||
$cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
|
||||
return wfMessage( 'newsectionsummary' )
|
||||
->rawParams( $cleanSectionTitle )->inContentLanguage()->text();
|
||||
}
|
||||
} elseif ( $this->summary !== '' ) {
|
||||
$sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
|
||||
# This is a new section, so create a link to the new section
|
||||
# in the revision summary.
|
||||
$cleanSummary = $wgParser->stripSectionName( $this->summary );
|
||||
return wfMessage( 'newsectionsummary' )
|
||||
->rawParams( $cleanSummary )->inContentLanguage()->text();
|
||||
} else {
|
||||
return $this->summary;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt submission (no UI)
|
||||
*
|
||||
|
|
@ -1764,31 +1795,11 @@ class EditPage {
|
|||
if ( $this->sectiontitle !== '' ) {
|
||||
// Insert the section title above the content.
|
||||
$content = $content->addSectionHeader( $this->sectiontitle );
|
||||
|
||||
// Jump to the new section
|
||||
$result['sectionanchor'] =
|
||||
$wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
|
||||
|
||||
// If no edit summary was specified, create one automatically from the section
|
||||
// title and have it link to the new section. Otherwise, respect the summary as
|
||||
// passed.
|
||||
if ( $this->summary === '' ) {
|
||||
$cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
|
||||
$this->summary = wfMessage( 'newsectionsummary' )
|
||||
->rawParams( $cleanSectionTitle )->inContentLanguage()->text();
|
||||
}
|
||||
} elseif ( $this->summary !== '' ) {
|
||||
// Insert the section title above the content.
|
||||
$content = $content->addSectionHeader( $this->summary );
|
||||
|
||||
// Jump to the new section
|
||||
$result['sectionanchor'] = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
|
||||
|
||||
// Create a link to the new section from the edit summary.
|
||||
$cleanSummary = $wgParser->stripSectionName( $this->summary );
|
||||
$this->summary = wfMessage( 'newsectionsummary' )
|
||||
->rawParams( $cleanSummary )->inContentLanguage()->text();
|
||||
}
|
||||
$this->summary = $this->newSectionSummary( $result['sectionanchor'] );
|
||||
}
|
||||
|
||||
$status->value = self::AS_SUCCESS_NEW_ARTICLE;
|
||||
|
|
@ -1806,7 +1817,8 @@ class EditPage {
|
|||
$this->isConflict = true;
|
||||
if ( $this->section == 'new' ) {
|
||||
if ( $this->mArticle->getUserText() == $wgUser->getName() &&
|
||||
$this->mArticle->getComment() == $this->summary ) {
|
||||
$this->mArticle->getComment() == $this->newSectionSummary()
|
||||
) {
|
||||
// Probably a duplicate submission of a new comment.
|
||||
// This can happen when squid resends a request after
|
||||
// a timeout but the first one actually went through.
|
||||
|
|
@ -1920,24 +1932,7 @@ class EditPage {
|
|||
wfProfileIn( __METHOD__ . '-sectionanchor' );
|
||||
$sectionanchor = '';
|
||||
if ( $this->section == 'new' ) {
|
||||
if ( $this->sectiontitle !== '' ) {
|
||||
$sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
|
||||
// If no edit summary was specified, create one automatically from the section
|
||||
// title and have it link to the new section. Otherwise, respect the summary as
|
||||
// passed.
|
||||
if ( $this->summary === '' ) {
|
||||
$cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
|
||||
$this->summary = wfMessage( 'newsectionsummary' )
|
||||
->rawParams( $cleanSectionTitle )->inContentLanguage()->text();
|
||||
}
|
||||
} elseif ( $this->summary !== '' ) {
|
||||
$sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
|
||||
# This is a new section, so create a link to the new section
|
||||
# in the revision summary.
|
||||
$cleanSummary = $wgParser->stripSectionName( $this->summary );
|
||||
$this->summary = wfMessage( 'newsectionsummary' )
|
||||
->rawParams( $cleanSummary )->inContentLanguage()->text();
|
||||
}
|
||||
$this->summary = $this->newSectionSummary( $sectionanchor );
|
||||
} elseif ( $this->section != '' ) {
|
||||
# Try to get a section anchor from the section source, redirect
|
||||
# to edited section if header found.
|
||||
|
|
|
|||
Loading…
Reference in a new issue