public function __construct( ApiMain $main, $format ) {
parent::__construct( $main, $format );
$this->isRaw = ( $format === 'rawfm' );
+
+ if ( $this->getMain()->getCheck( 'callback' ) ) {
+ # T94015: jQuery appends a useless '_' parameter in jsonp mode.
+ # Mark the parameter as used in that case to avoid a warning that's
+ # outside the control of the end user.
+ # (and do it here because ApiMain::reportUnusedParams() gets called
+ # before our ::execute())
+ $this->getMain()->getCheck( '_' );
+ }
}
public function getMimeType() {
$params = $this->extractRequestParams();
// callback:
- if ( $params['callback'] ) {
+ if ( isset( $params['callback'] ) ) {
return 'text/javascript';
}
break;
default:
- self::dieUsage( __METHOD__ . ': Unknown value for \'formatversion\'' );
+ $this->dieUsage( __METHOD__ . ': Unknown value for \'formatversion\'', 'unknownformatversion' );
}
}
$data = $this->getResult()->getResultData( null, $transform );
);
}
- $callback = $params['callback'];
- if ( $callback !== null ) {
- $callback = preg_replace( "/[^][.\\'\\\"_A-Za-z0-9]/", '', $callback );
+ if ( isset( $params['callback'] ) ) {
+ $callback = preg_replace( "/[^][.\\'\\\"_A-Za-z0-9]/", '', $params['callback'] );
# Prepend a comment to try to avoid attacks against content
# sniffers, such as bug 68187.
$this->printText( "/**/$callback($json)" );