Avoid User::getEditCount() and ::getOption()

The latter is deprecated, and the former is just a wrapper for
UserEditTracker::getUserEditCount().

Bug: T290521
Change-Id: Id3f2b9a007fe299d74d5957cbd3e31b11adb2790
This commit is contained in:
Sam Wilson 2021-11-04 16:04:38 +08:00
parent d5175e8695
commit d23389cd06

View file

@ -111,7 +111,8 @@ class WikiEditorHooks {
} }
$user = $article->getContext()->getUser(); $user = $article->getContext()->getUser();
$services = MediaWikiServices::getInstance();
$editCount = $services->getUserEditTracker()->getUserEditCount( $user );
$data = [ $data = [
'feature' => $feature, 'feature' => $feature,
'action' => $action, 'action' => $action,
@ -121,11 +122,12 @@ class WikiEditorHooks {
'integration' => 'page', 'integration' => 'page',
'editor_interface' => 'wikitext', 'editor_interface' => 'wikitext',
'user_id' => $user->getId(), 'user_id' => $user->getId(),
'user_editcount' => $user->getEditCount() ?: 0, 'user_editcount' => $editCount ?: 0,
]; ];
if ( $user->getOption( 'discussiontools-abtest' ) ) { $bucket = $services->getUserOptionsLookup()->getOption( $user, 'discussiontools-abtest' );
$data['bucket'] = $user->getOption( 'discussiontools-abtest' ); if ( $bucket ) {
$data['bucket'] = $bucket;
} }
return EventLogging::logEvent( 'VisualEditorFeatureUse', 21199762, $data ); return EventLogging::logEvent( 'VisualEditorFeatureUse', 21199762, $data );