Make WikitextContent::getSection() return false when the section is
missing, as per the documented behaviour for Content::getSection(). Fix
a test so that it doesn't generate a PHP fatal error if getSection()
returns false.
Should fix the current Jenkins build failure:
https://integration.mediawiki.org/ci/job/MediaWiki-Tests-Misc/6989/testReport/junit/%28root%29/WikitextContentTest__testGetSection/testGetSection_with_data_set__2/
Change-Id: Ifa85f8eed50943d8ece32555d06b3e989077da46
$text = $this->getNativeData();
$sect = $wgParser->getSection( $text, $section, false );
- return new WikitextContent( $sect );
+ if ( $sect === false ) {
+ return false;
+ } else {
+ return new WikitextContent( $sect );
+ }
}
/**
public function matchMagicWord( MagicWord $word ) {
return $word->match( $this->getNativeData() );
}
-}
\ No newline at end of file
+}
$content = $this->newContent( $text );
$sectionContent = $content->getSection( $sectionId );
+ if ( is_object( $sectionContent ) ) {
+ $sectionText = $sectionContent->getNativeData();
+ } else {
+ $sectionText = $sectionContent;
+ }
- $this->assertEquals( $expectedText, is_null( $sectionContent ) ? null : $sectionContent->getNativeData() );
+ $this->assertEquals( $expectedText, $sectionText );
}
public function dataReplaceSection() {