From: Fomafix Date: Mon, 2 May 2016 14:09:06 +0000 (+0000) Subject: API: Avoid duplicate IDs in API documentation X-Git-Tag: 1.31.0-rc.0~6905^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=5233d832025e2170a90498e6530c8e20a03fb040;p=lhc%2Fweb%2Fwiklou.git 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 --- 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();