Skip to content

Commit

Permalink
Replace deprecated functions call
Browse files Browse the repository at this point in the history
Change-Id: Iebc7a5faa4854aafee1e27494604435cf547392a
  • Loading branch information
pastakhov committed Dec 13, 2022
1 parent f99e696 commit 6067870
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 198 deletions.
27 changes: 15 additions & 12 deletions includes/specials/SpecialCloseAccount.php
Expand Up @@ -11,22 +11,25 @@
* @see https://bugzilla.shoutwiki.com/show_bug.cgi?id=294
*/

use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserGroupManager;
use MediaWiki\User\UserNameUtils;

// @note Extends EditAccount so that we don't have to duplicate closeAccount() etc.
class CloseAccount extends EditAccount {

/**
* @var User User object for the account that is to be disabled
* @var null|User User object for the account that is to be disabled
*/
public $mUser;
public ?User $mUser;

/** @var UserGroupManager */
private $userGroupManager;
/**
* @var UserGroupManager
*/
private UserGroupManager $userGroupManager;

/** @var UserNameUtils */
private $userNameUtils;
private UserNameUtils $userNameUtils;

/**
* Constructor -- set up the new special page
Expand All @@ -48,7 +51,7 @@ public function __construct(
*
* @return string
*/
public function getGroupName() {
public function getGroupName(): string {
return 'users';
}

Expand All @@ -57,7 +60,7 @@ public function getGroupName() {
*
* @return string Special page description
*/
public function getDescription() {
public function getDescription(): string {
return $this->msg( 'editaccount-general-description' )->plain();
}

Expand All @@ -67,7 +70,7 @@ public function getDescription() {
*
* @return bool
*/
public function isListed() {
public function isListed(): bool {
$user = $this->getUser();
$effectiveGroups = $this->userGroupManager->getUserEffectiveGroups( $user );
$isStaff = in_array( 'staff', $effectiveGroups );
Expand All @@ -77,9 +80,9 @@ public function isListed() {
/**
* Show the special page
*
* @param string|null $par Parameter (user name) passed to the page or null
* @param string|null $subPage Parameter (user name) passed to the page or null
*/
public function execute( $par ) {
public function execute( $subPage ) {
$out = $this->getOutput();
$request = $this->getRequest();
$user = $this->getUser();
Expand Down Expand Up @@ -119,7 +122,7 @@ public function execute( $par ) {

// Check if user name is an existing user
if ( $this->userNameUtils->isValid( $userName ) ) {
$this->mUser = User::newFromName( $userName );
$this->mUser = MediaWikiServices::getInstance()->getUserFactory()->newFromName( $userName );
}

$changeReason = $request->getVal( 'wpReason' );
Expand All @@ -135,7 +138,7 @@ public function execute( $par ) {
$out->addHTML(
"<fieldset>\n<legend>" . $this->msg( 'editaccount-status' )->escaped() .
'</legend>' .
Xml::element( 'span', [ 'style' => "color: {$color}; font-weight: bold;" ], $this->mStatusMsg ) .
Xml::element( 'span', [ 'style' => "color: $color; font-weight: bold;" ], $this->mStatusMsg ) .
'</fieldset>'
);
} else {
Expand Down

0 comments on commit 6067870

Please sign in to comment.