Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -1132,7 +1132,7 @@ |
1133 | 1133 | $text = $this->textbox1; |
1134 | 1134 | $result['sectionanchor'] = ''; |
1135 | 1135 | if ( $this->section == 'new' ) { |
1136 | | - if ( $this->sectiontitle != '' ) { |
| 1136 | + if ( $this->sectiontitle !== '' ) { |
1137 | 1137 | // Insert the section title above the content. |
1138 | 1138 | $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->sectiontitle ) . "\n\n" . $text; |
1139 | 1139 | |
— | — | @@ -1142,11 +1142,11 @@ |
1143 | 1143 | // If no edit summary was specified, create one automatically from the section |
1144 | 1144 | // title and have it link to the new section. Otherwise, respect the summary as |
1145 | 1145 | // passed. |
1146 | | - if ( $this->summary == '' ) { |
| 1146 | + if ( $this->summary === '' ) { |
1147 | 1147 | $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle ); |
1148 | 1148 | $this->summary = wfMsgForContent( 'newsectionsummary', $cleanSectionTitle ); |
1149 | 1149 | } |
1150 | | - } elseif ( $this->summary != '' ) { |
| 1150 | + } elseif ( $this->summary !== '' ) { |
1151 | 1151 | // Insert the section title above the content. |
1152 | 1152 | $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->summary ) . "\n\n" . $text; |
1153 | 1153 | |
— | — | @@ -1189,14 +1189,22 @@ |
1190 | 1190 | $this->isConflict = false; |
1191 | 1191 | } |
1192 | 1192 | } |
1193 | | - |
| 1193 | + |
| 1194 | + // If sectiontitle is set, use it, otherwise use the summary as the section title (for |
| 1195 | + // backwards compatibility with old forms/bots). |
| 1196 | + if ( $this->sectiontitle !== '' ) { |
| 1197 | + $sectionTitle = $this->sectiontitle; |
| 1198 | + } else { |
| 1199 | + $sectionTitle = $this->summary; |
| 1200 | + } |
| 1201 | + |
1194 | 1202 | if ( $this->isConflict ) { |
1195 | 1203 | wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '" . |
1196 | 1204 | $this->mArticle->getTimestamp() . "')\n" ); |
1197 | | - $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime ); |
| 1205 | + $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime ); |
1198 | 1206 | } else { |
1199 | 1207 | wfDebug( __METHOD__ . ": getting section '$this->section'\n" ); |
1200 | | - $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary ); |
| 1208 | + $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle ); |
1201 | 1209 | } |
1202 | 1210 | if ( is_null( $text ) ) { |
1203 | 1211 | wfDebug( __METHOD__ . ": activating conflict; section replace failed.\n" ); |
— | — | @@ -1273,7 +1281,16 @@ |
1274 | 1282 | wfProfileOut( __METHOD__ ); |
1275 | 1283 | return $status; |
1276 | 1284 | } |
1277 | | - if ( $this->summary != '' ) { |
| 1285 | + if ( $this->sectiontitle !== '' ) { |
| 1286 | + $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle ); |
| 1287 | + // If no edit summary was specified, create one automatically from the section |
| 1288 | + // title and have it link to the new section. Otherwise, respect the summary as |
| 1289 | + // passed. |
| 1290 | + if ( $this->summary === '' ) { |
| 1291 | + $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle ); |
| 1292 | + $this->summary = wfMsgForContent( 'newsectionsummary', $cleanSectionTitle ); |
| 1293 | + } |
| 1294 | + } elseif ( $this->summary !== '' ) { |
1278 | 1295 | $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary ); |
1279 | 1296 | # This is a new section, so create a link to the new section |
1280 | 1297 | # in the revision summary. |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -978,11 +978,11 @@ |
979 | 979 | /** |
980 | 980 | * @param $section empty/null/false or a section number (0, 1, 2, T1, T2...) |
981 | 981 | * @param $text String: new text of the section |
982 | | - * @param $summary String: new section's subject, only if $section is 'new' |
| 982 | + * @param $sectionTitle String: new section's subject, only if $section is 'new' |
983 | 983 | * @param $edittime String: revision timestamp or null to use the current revision |
984 | 984 | * @return string Complete article text, or null if error |
985 | 985 | */ |
986 | | - public function replaceSection( $section, $text, $summary = '', $edittime = null ) { |
| 986 | + public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { |
987 | 987 | wfProfileIn( __METHOD__ ); |
988 | 988 | |
989 | 989 | if ( strval( $section ) == '' ) { |
— | — | @@ -1006,7 +1006,7 @@ |
1007 | 1007 | |
1008 | 1008 | if ( $section == 'new' ) { |
1009 | 1009 | # Inserting a new section |
1010 | | - $subject = $summary ? wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" : ''; |
| 1010 | + $subject = $sectionTitle ? wfMsgForContent( 'newsectionheaderdefaultlevel', $sectionTitle ) . "\n\n" : ''; |
1011 | 1011 | if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) { |
1012 | 1012 | $text = strlen( trim( $oldtext ) ) > 0 |
1013 | 1013 | ? "{$oldtext}\n\n{$subject}{$text}" |