/**
* Set the continuation manager
- * @param ApiContinuationManager|null
+ * @param ApiContinuationManager|null $manager
*/
public function setContinuationManager( $manager ) {
if ( $manager !== null ) {
// T65145: Rollback any open database transactions
if ( !( $e instanceof ApiUsageException || $e instanceof UsageException ) ) {
// UsageExceptions are intentional, so don't rollback if that's the case
- try {
- MWExceptionHandler::rollbackMasterChangesAndLog( $e );
- } catch ( DBError $e2 ) {
- // Rollback threw an exception too. Log it, but don't interrupt
- // our regularly scheduled exception handling.
- MWExceptionHandler::logException( $e2 );
- }
+ MWExceptionHandler::rollbackMasterChangesAndLog( $e );
}
// Allow extra cleanup and logging
Hooks::run( 'ApiMain::onException', [ $this, $e ] );
- // Log it
- if ( !( $e instanceof ApiUsageException || $e instanceof UsageException ) ) {
- MWExceptionHandler::logException( $e );
- }
-
// Handle any kind of exception by outputting properly formatted error message.
// If this fails, an unhandled exception should be thrown so that global error
// handler will process and log it.
// None of the rest have any messages for non-error types
} elseif ( $e instanceof UsageException ) {
// User entered incorrect parameters - generate error response
- $data = $e->getMessageArray();
+ $data = MediaWiki\quietCall( [ $e, 'getMessageArray' ] );
$code = $data['code'];
$info = $data['info'];
unset( $data['code'], $data['info'] );
ApiBase::PARAM_TYPE => 'submodule',
],
'format' => [
- ApiBase::PARAM_DFLT => ApiMain::API_DEFAULT_FORMAT,
+ ApiBase::PARAM_DFLT => self::API_DEFAULT_FORMAT,
ApiBase::PARAM_TYPE => 'submodule',
],
'maxlag' => [
$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' ],
- $header
+ $id = Sanitizer::escapeIdForAttribute( 'main/datatypes', Sanitizer::ID_PRIMARY );
+ $idFallback = Sanitizer::escapeIdForAttribute( 'main/datatypes', Sanitizer::ID_FALLBACK );
+ $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 = '<div id="main/datatypes"></div>' . $headline;
+ }
+ $help['datatypes'] .= $headline;
$help['datatypes'] .= $this->msg( 'api-help-datatypes' )->parseAsBlock();
if ( !isset( $tocData['main/datatypes'] ) ) {
$tocnumber[$level]++;
];
}
- // 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' ],
- $header
+ $id = Sanitizer::escapeIdForAttribute( 'main/credits', Sanitizer::ID_PRIMARY );
+ $idFallback = Sanitizer::escapeIdForAttribute( 'main/credits', Sanitizer::ID_FALLBACK );
+ $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 = '<div id="main/credits"></div>' . $headline;
+ }
+ $help['credits'] .= $headline;
$help['credits'] .= $this->msg( 'api-credits' )->useDatabase( false )->parseAsBlock();
if ( !isset( $tocData['main/credits'] ) ) {
$tocnumber[$level]++;