From: daniel Date: Mon, 23 Jul 2012 11:19:22 +0000 (+0200) Subject: fix replaceSection for models that don't support sections X-Git-Tag: 1.31.0-rc.0~22097^2^2~74 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=d098dc8cdcc390ea80c742c0dc36bdad1e631da9;p=lhc%2Fweb%2Fwiklou.git fix replaceSection for models that don't support sections Change-Id: Ib60c616f572bf143e3ea63f269f7a0b0701f144c --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 48da565e1d..8225d5a6a7 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2531,8 +2531,8 @@ HTML $this->content_model, $this->content_format ); #XXX: handle parse errors ? $newContent = $this->mArticle->replaceSectionContent( - $this->section, $textboxContent, - $this->summary, $this->edittime ); + $this->section, $textboxContent, + $this->summary, $this->edittime ); # hanlde legacy text-based hook $newtext_orig = $newContent->serialize( $this->content_format ); diff --git a/includes/WikiPage.php b/includes/WikiPage.php index ad1fded5a6..23fbce2fbb 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1423,8 +1423,13 @@ class WikiPage extends Page { public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { wfDeprecated( __METHOD__, '1.WD' ); + if ( strval( $section ) == '' ) { //NOTE: keep condition in sync with condition in replaceSectionContent! + // Whole-page edit; let the whole text through + return $text; + } + if ( !$this->supportsSections() ) { - return null; + throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() ); } $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); # could even make section title, but that's not required. @@ -1459,15 +1464,14 @@ class WikiPage extends Page { public function replaceSectionContent( $section, Content $sectionContent, $sectionTitle = '', $edittime = null ) { wfProfileIn( __METHOD__ ); - if ( !$this->supportsSections() ) { - #XXX: log this? - return null; - } - if ( strval( $section ) == '' ) { // Whole-page edit; let the whole text through $newContent = $sectionContent; } else { + if ( !$this->supportsSections() ) { + throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() ); + } + // Bug 30711: always use current version when adding a new section if ( is_null( $edittime ) || $section == 'new' ) { $oldContent = $this->getContent();