TheDJ has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/198092

Change subject: ApiParse: Fix parse of new section title
......................................................................

ApiParse: Fix parse of new section title

Mirror how EditPage transforms a new sectiontitle to be gray, have
the arrow etc...

Bug: T84877
Change-Id: If4d8fd11386c87a5b6d51b6afbeae737b3a829a5
---
M includes/api/ApiParse.php
1 file changed, 16 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/92/198092/1

diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 20592ca..2acf7a9 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -230,10 +230,7 @@
                                }
                                if ( !is_null( $params['summary'] ) ) {
                                        $result_array['parsedsummary'] = 
array();
-                                       ApiResult::setContent(
-                                               $result_array['parsedsummary'],
-                                               Linker::formatComment( 
$params['summary'], $titleObj )
-                                       );
+                                       ApiResult::setContent( 
$result_array['parsedsummary'], $this->formatSummary( $params['summary'], 
$titleObj ) );
                                }
 
                                $result->addValue( null, 
$this->getModuleName(), $result_array );
@@ -272,10 +269,7 @@
 
                if ( !is_null( $params['summary'] ) ) {
                        $result_array['parsedsummary'] = array();
-                       ApiResult::setContent(
-                               $result_array['parsedsummary'],
-                               Linker::formatComment( $params['summary'], 
$titleObj )
-                       );
+                       ApiResult::setContent( $result_array['parsedsummary'], 
$this->formatSummary( $params['summary'], $titleObj ) );
                }
 
                if ( isset( $prop['langlinks'] ) ) {
@@ -499,6 +493,20 @@
                return $section;
        }
 
+       /**
+        * @param String $summary to parse
+        * @param Title $title of the page being parsed
+        * @return Content|bool
+        */
+       private function formatSummary( $summary, $title ) {
+               global $wgParser;
+               if ( $this->section === 'new' ) {
+                       $summary = wfMessage( 'newsectionsummary' )->rawParams( 
$wgParser->stripSectionName( $summary ) )
+                               ->inContentLanguage()->text();
+               }
+               return Linker::formatComment( $summary, $titleObj, 
$this->section === 'new' );
+       }
+
        private function formatLangLinks( $links ) {
                $result = array();
                foreach ( $links as $link ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/198092
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4d8fd11386c87a5b6d51b6afbeae737b3a829a5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: TheDJ <hartman.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to