* @return string
*/
public function getContentType() {
- // Use getRawVal instead of getVal because we only
- // need to match against known strings, there is no
- // storing of localised content or other user input.
+ // Optimisation: Avoid slow getVal(), this isn't user-generated content.
$ctype = $this->getRequest()->getRawVal( 'ctype' );
if ( $ctype == '' ) {
// Setup uselang. This doesn't use $this->getParameter()
// because we're not ready to handle errors yet.
- $uselang = $request->getVal( 'uselang', self::API_DEFAULT_USELANG );
+ // Optimisation: Avoid slow getVal(), this isn't user-generated content.
+ $uselang = $request->getRawVal( 'uselang', self::API_DEFAULT_USELANG );
if ( $uselang === 'user' ) {
// Assume the parent context is going to return the user language
// for uselang=user (see T85635).
// Set up the error formatter. This doesn't use $this->getParameter()
// because we're not ready to handle errors yet.
- $errorFormat = $request->getVal( 'errorformat', 'bc' );
- $errorLangCode = $request->getVal( 'errorlang', 'uselang' );
+ // Optimisation: Avoid slow getVal(), this isn't user-generated content.
+ $errorFormat = $request->getRawVal( 'errorformat', 'bc' );
+ $errorLangCode = $request->getRawVal( 'errorlang', 'uselang' );
$errorsUseDB = $request->getCheck( 'errorsuselocal' );
if ( in_array( $errorFormat, [ 'plaintext', 'wikitext', 'html', 'raw', 'none' ], true ) ) {
if ( $errorLangCode === 'uselang' ) {
$request = $this->getRequest();
$user = $this->getUser();
- $code = $request->getVal( 'uselang', 'user' );
+ // Optimisation: Avoid slow getVal(), this isn't user-generated content.
+ $code = $request->getRawVal( 'uselang', 'user' );
if ( $code === 'user' ) {
$code = $user->getOption( 'language' );
}
if ( !in_array( 'skin', $this->getConfig()->get( 'HiddenPrefs' ) ) ) {
# get the user skin
$userSkin = $this->getUser()->getOption( 'skin' );
- $userSkin = $this->getRequest()->getVal( 'useskin', $userSkin );
+ // Optimisation: Avoid slow getVal(), this isn't user-generated content.
+ $userSkin = $this->getRequest()->getRawVal( 'useskin', $userSkin );
} else {
# if we're not allowing users to override, then use the default
$userSkin = $this->getConfig()->get( 'DefaultSkin' );
$this->request = $request;
$this->logger = $resourceLoader->getLogger();
- // Future developers: Use WebRequest::getRawVal() instead of getVal().
- // The getVal() method performs slow Language+UTF logic. (f303bb9360)
+ // Optimisation: Use WebRequest::getRawVal() instead of getVal(). We don't
+ // need the slow Language+UTF logic meant for user input here. (f303bb9360)
// List of modules
$modules = $request->getRawVal( 'modules' );