From: Brad Jorsch Date: Wed, 2 Aug 2017 22:45:01 +0000 (-0400) Subject: Restore non-mangled anchors in API help in all cases X-Git-Tag: 1.31.0-rc.0~2383^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/%7B%7B%20url_for%28%27vote%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=7e92dc49f2407a56670a47f248b0aa209e456483;p=lhc%2Fweb%2Fwiklou.git Restore non-mangled anchors in API help in all cases Prior to Id304010a, the API help included non-mangled anchors even when $wgExperimentalHtmlIds was false. This was lost in Id304010a when the new $wgFragmentMode is [ 'legacy' ], as is the default, despite the loss being pointed out multiple times in code review. Change-Id: Ibcb86deb4e3ea2131211f184f46960e5ad390212 --- diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index f6dd524886..e69300bb3b 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -1933,14 +1933,18 @@ class ApiMain extends ApiBase { $id = Sanitizer::escapeIdForAttribute( 'main/datatypes', Sanitizer::ID_PRIMARY ); $idFallback = Sanitizer::escapeIdForAttribute( 'main/datatypes', Sanitizer::ID_FALLBACK ); - - $help['datatypes'] .= Linker::makeHeadline( min( 6, $level ), + $headline = Linker::makeHeadline( min( 6, $level ), ' class="apihelp-header"', $id, $header, '', $idFallback ); + // Ensure we have a sane anchor + if ( $id !== 'main/datatypes' && $idFallback !== 'main/datatypes' ) { + $headline = '
' . $headline; + } + $help['datatypes'] .= $headline; $help['datatypes'] .= $this->msg( 'api-help-datatypes' )->parseAsBlock(); if ( !isset( $tocData['main/datatypes'] ) ) { $tocnumber[$level]++; @@ -1957,13 +1961,18 @@ class ApiMain extends ApiBase { $header = $this->msg( 'api-credits-header' )->parse(); $id = Sanitizer::escapeIdForAttribute( 'main/credits', Sanitizer::ID_PRIMARY ); $idFallback = Sanitizer::escapeIdForAttribute( 'main/credits', Sanitizer::ID_FALLBACK ); - $help['credits'] .= Linker::makeHeadline( min( 6, $level ), + $headline = Linker::makeHeadline( min( 6, $level ), ' class="apihelp-header"', $id, $header, '', $idFallback ); + // Ensure we have a sane anchor + if ( $id !== 'main/credits' && $idFallback !== 'main/credits' ) { + $headline = '
' . $headline; + } + $help['credits'] .= $headline; $help['credits'] .= $this->msg( 'api-credits' )->useDatabase( false )->parseAsBlock(); if ( !isset( $tocData['main/credits'] ) ) { $tocnumber[$level]++;