Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption() Bug: T277818 Change-Id: I5ac58c4be5046d4457de24b63b062aa238e972b6
This commit is contained in:
committed by
jenkins-bot
parent
77b61af6b8
commit
0d9e1b134a
@@ -33,7 +33,12 @@
|
|||||||
"APIModules": {
|
"APIModules": {
|
||||||
"languagesearch": "ApiLanguageSearch",
|
"languagesearch": "ApiLanguageSearch",
|
||||||
"ulslocalization": "ApiULSLocalization",
|
"ulslocalization": "ApiULSLocalization",
|
||||||
"ulssetlang": "ApiULSSetLanguage"
|
"ulssetlang": {
|
||||||
|
"class": "ApiULSSetLanguage",
|
||||||
|
"services": [
|
||||||
|
"UserOptionsManager"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"MessagesDirs": {
|
"MessagesDirs": {
|
||||||
"UniversalLanguageSelector": [
|
"UniversalLanguageSelector": [
|
||||||
|
|||||||
@@ -18,10 +18,29 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use MediaWiki\User\UserOptionsManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup API
|
* @ingroup API
|
||||||
*/
|
*/
|
||||||
class ApiULSSetLanguage extends ApiBase {
|
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() {
|
public function execute() {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
if ( !$request->wasPosted() ) {
|
if ( !$request->wasPosted() ) {
|
||||||
@@ -53,7 +72,7 @@ class ApiULSSetLanguage extends ApiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$updateUser = $user->getInstanceForUpdate();
|
$updateUser = $user->getInstanceForUpdate();
|
||||||
$updateUser->setOption( 'language', $languageCode );
|
$this->userOptionsManager->setOption( $updateUser, 'language', $languageCode );
|
||||||
// Sync the DB on post-send
|
// Sync the DB on post-send
|
||||||
DeferredUpdates::addCallableUpdate( static function () use ( $updateUser ) {
|
DeferredUpdates::addCallableUpdate( static function () use ( $updateUser ) {
|
||||||
$updateUser->saveSettings();
|
$updateUser->saveSettings();
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ class ULSCompactLinksDisablePref extends Maintenance {
|
|||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
$dbr = wfGetDB( DB_REPLICA, 'vslow' );
|
$dbr = wfGetDB( DB_REPLICA, 'vslow' );
|
||||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
$services = MediaWikiServices::getInstance();
|
||||||
|
$lbFactory = $services->getDBLoadBalancerFactory();
|
||||||
|
$userOptionsManager = $services->getUserOptionsManager();
|
||||||
|
|
||||||
$really = $this->hasOption( 'really' );
|
$really = $this->hasOption( 'really' );
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ class ULSCompactLinksDisablePref extends Maintenance {
|
|||||||
$user->load( User::READ_LATEST );
|
$user->load( User::READ_LATEST );
|
||||||
|
|
||||||
if ( $really ) {
|
if ( $really ) {
|
||||||
$user->setOption( 'compact-language-links', 0 );
|
$userOptionsManager->setOption( $user, 'compact-language-links', 0 );
|
||||||
|
|
||||||
$user->saveSettings();
|
$user->saveSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user