$wgOut->addWikiMsg( 'nonunicodebrowser' );
}
- if ( isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) {
+ if ( $this->section != 'new' && isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) {
// Let sysop know that this will make private content public if saved
if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) {
function showDiff() {
global $wgUser, $wgContLang, $wgParser;
- $oldtext = $this->mArticle->fetchContent();
+ if ( $this->section == 'new' ) {
+ $oldtext = $this->mArticle->getRawText();
+ } else {
+ $oldtext = $this->mArticle->fetchContent();
+ }
$newtext = $this->mArticle->replaceSection(
$this->section, $this->textbox1, $this->summary, $this->edittime );
if ( strval( $section ) == '' ) {
// Whole-page edit; let the whole text through
} else {
- if ( is_null( $edittime ) ) {
- $rev = Revision::newFromTitle( $this->mTitle );
+ // Bug 30711: always use current version when adding a new section
+ if ( is_null( $edittime ) || $section == 'new' ) {
+ $oldtext = $this->getRawText();
+ if ( $oldtext === false ) {
+ wfDebug( __METHOD__ . ": no page text\n" );
+ return null;
+ }
} else {
$dbw = wfGetDB( DB_MASTER );
$rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime );
- }
- if ( !$rev ) {
- wfDebug( "WikiPage::replaceSection asked for bogus section (page: " .
- $this->getId() . "; section: $section; edittime: $edittime)\n" );
- wfProfileOut( __METHOD__ );
- return null;
- }
+ if ( !$rev ) {
+ wfDebug( "WikiPage::replaceSection asked for bogus section (page: " .
+ $this->getId() . "; section: $section; edittime: $edittime)\n" );
+ wfProfileOut( __METHOD__ );
+ return null;
+ }
- $oldtext = $rev->getText();
+ $oldtext = $rev->getText();
+ }
if ( $section == 'new' ) {
# Inserting a new section