replaceAll.php: Replace get_class with instanceof

The User class was namespaced in 1d0b7ae1,
checking class names as string is broken, use instanceof.
There are no subclasses of User class to ignore at this point.

Also use User::getName instead of implicit User::__toString

Change-Id: I8b9f73609a7ef9f781c8a5ae27e00d612d33ee4f
这个提交包含在:
Umherirrender 2024-01-05 21:26:44 +01:00 提交者 WaitSpring
父节点 a512649ce2
当前提交 35984ebb37
共有 1 个文件被更改,包括 3 次插入2 次删除

查看文件

@ -30,6 +30,7 @@
namespace MediaWiki\Extension\ReplaceText;
use Maintenance;
use MediaWiki\User\User;
use MWException;
$IP = getenv( 'MW_INSTALL_PATH' ) ?: __DIR__ . '/../../..';
@ -112,7 +113,7 @@ class ReplaceAll extends Maintenance {
$userFactory->newFromId( $userReplacing ) :
$userFactory->newFromName( $userReplacing );
if ( get_class( $user ) !== 'User' ) {
if ( !$user instanceof User ) {
$this->fatalError(
"Couldn't translate '$userReplacing' to a user."
);
@ -437,7 +438,7 @@ EOF;
$this->botEdit = true;
}
if ( !$this->getReply(
"Attribute changes to the user '{$this->user}'?$comment"
"Attribute changes to the user '{$this->user->getName()}'?$comment"
) ) {
return;
}