X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fcontent%2FWikitextContent.php;h=d649baf89cc743845344c7782dd6a6ec3b736593;hp=a63819dd422f73262163577bbf6ea1b5d4071503;hb=326d655fc9309f55112538b387ed8c201158a27d;hpb=a5b975edd132e52ee8ce1c725d8195da941c8b7b diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index a63819dd42..5beef31b8c 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -38,7 +38,7 @@ class WikitextContent extends TextContent { } /** - * @param string|number $sectionId + * @param string|int $sectionId * * @return Content|bool|null * @@ -58,7 +58,7 @@ class WikitextContent extends TextContent { } /** - * @param string|number|null|bool $sectionId + * @param string|int|null|bool $sectionId * @param Content $with * @param string $sectionTitle * @@ -68,7 +68,6 @@ class WikitextContent extends TextContent { * @see Content::replaceSection() */ public function replaceSection( $sectionId, Content $with, $sectionTitle = '' ) { - $myModelId = $this->getModel(); $sectionModelId = $with->getModel(); @@ -88,7 +87,7 @@ class WikitextContent extends TextContent { if ( $sectionId === 'new' ) { # Inserting a new section $subject = $sectionTitle ? wfMessage( 'newsectionheaderdefaultlevel' ) - ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : ''; + ->plaintextParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : ''; if ( Hooks::run( 'PlaceNewSection', [ $this, $oldtext, $subject, &$text ] ) ) { $text = strlen( trim( $oldtext ) ) > 0 ? "{$oldtext}\n\n{$subject}{$text}" @@ -138,7 +137,6 @@ class WikitextContent extends TextContent { $text = $this->getNativeData(); $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts ); - rtrim( $pst ); return ( $text === $pst ) ? $this : new static( $pst ); } @@ -272,28 +270,22 @@ class WikitextContent extends TextContent { return false; } - switch ( $wgArticleCountMethod ) { - case 'any': - return true; - case 'comma': - $text = $this->getNativeData(); - return strpos( $text, ',' ) !== false; - case 'link': - if ( $hasLinks === null ) { # not known, find out - if ( !$title ) { - $context = RequestContext::getMain(); - $title = $context->getTitle(); - } - - $po = $this->getParserOutput( $title, null, null, false ); - $links = $po->getLinks(); - $hasLinks = !empty( $links ); + if ( $wgArticleCountMethod === 'link' ) { + if ( $hasLinks === null ) { # not known, find out + if ( !$title ) { + $context = RequestContext::getMain(); + $title = $context->getTitle(); } - return $hasLinks; + $po = $this->getParserOutput( $title, null, null, false ); + $links = $po->getLinks(); + $hasLinks = !empty( $links ); + } + + return $hasLinks; } - return false; + return true; } /**