From 5233d832025e2170a90498e6530c8e20a03fb040 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Mon, 2 May 2016 14:09:06 +0000 Subject: [PATCH] API: Avoid duplicate IDs in API documentation With $wgExperimentalHtmlIds = true Sanitizer::escapeId( 'main/credits' ) is equal to 'main/credits'. This generate a duplicate ID. This change generates the additional only with $wgExperimentalHtmlIds = false. Bug: T134155 Change-Id: Ie5d692b7b166030b2bc5c426b44608d981274cd0 --- includes/api/ApiMain.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 07642c48ed..280565ea18 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -1630,9 +1630,14 @@ class ApiMain extends ApiBase { $tocnumber = &$options['tocnumber']; $header = $this->msg( 'api-help-datatypes-header' )->parse(); + + // Add an additional span with sanitized ID + if ( !$this->getConfig()->get( 'ExperimentalHtmlIds' ) ) { + $header = Html::element( 'span', [ 'id' => Sanitizer::escapeId( 'main/datatypes' ) ] ) . + $header; + } $help['datatypes'] .= Html::rawElement( 'h' . min( 6, $level ), [ 'id' => 'main/datatypes', 'class' => 'apihelp-header' ], - Html::element( 'span', [ 'id' => Sanitizer::escapeId( 'main/datatypes' ) ] ) . $header ); $help['datatypes'] .= $this->msg( 'api-help-datatypes' )->parseAsBlock(); @@ -1648,10 +1653,14 @@ class ApiMain extends ApiBase { ]; } + // Add an additional span with sanitized ID + if ( !$this->getConfig()->get( 'ExperimentalHtmlIds' ) ) { + $header = Html::element( 'span', [ 'id' => Sanitizer::escapeId( 'main/credits' ) ] ) . + $header; + } $header = $this->msg( 'api-credits-header' )->parse(); $help['credits'] .= Html::rawElement( 'h' . min( 6, $level ), [ 'id' => 'main/credits', 'class' => 'apihelp-header' ], - Html::element( 'span', [ 'id' => Sanitizer::escapeId( 'main/credits' ) ] ) . $header ); $help['credits'] .= $this->msg( 'api-credits' )->useDatabase( false )->parseAsBlock(); -- 2.20.1