summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/UniversalLanguageSelector/includes/api/ApiULSSetLanguage.php')
-rw-r--r--MLEB/UniversalLanguageSelector/includes/api/ApiULSSetLanguage.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/MLEB/UniversalLanguageSelector/includes/api/ApiULSSetLanguage.php b/MLEB/UniversalLanguageSelector/includes/api/ApiULSSetLanguage.php
index 715c6dd8..7d7717e9 100644
--- a/MLEB/UniversalLanguageSelector/includes/api/ApiULSSetLanguage.php
+++ b/MLEB/UniversalLanguageSelector/includes/api/ApiULSSetLanguage.php
@@ -18,10 +18,29 @@
* @license MIT
*/
+use MediaWiki\User\UserOptionsManager;
+
/**
* @ingroup API
*/
class ApiULSSetLanguage extends ApiBase {
+ /** @var UserOptionsManager */
+ private $userOptionsManager;
+
+ /**
+ * @param ApiMain $main
+ * @param string $action
+ * @param UserOptionsManager $userOptionsManager
+ */
+ public function __construct(
+ ApiMain $main,
+ $action,
+ UserOptionsManager $userOptionsManager
+ ) {
+ parent::__construct( $main, $action );
+ $this->userOptionsManager = $userOptionsManager;
+ }
+
public function execute() {
$request = $this->getRequest();
if ( !$request->wasPosted() ) {
@@ -53,9 +72,10 @@ class ApiULSSetLanguage extends ApiBase {
}
$updateUser = $user->getInstanceForUpdate();
- $updateUser->setOption( 'language', $languageCode );
+ // @phan-suppress-next-line SecurityCheck-SQLInjection False positive caused by T290563
+ $this->userOptionsManager->setOption( $updateUser, 'language', $languageCode );
// Sync the DB on post-send
- DeferredUpdates::addCallableUpdate( function () use ( $updateUser ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $updateUser ) {
$updateUser->saveSettings();
} );
}