Merge "Fixes for talk_page_edit logging"

This commit is contained in:
jenkins-bot 2021-11-19 17:26:14 +00:00 committed by Gerrit Code Review
commit 0e00c6e96d

View file

@ -347,8 +347,9 @@ class EventDispatcher {
* @return bool Whether events were logged * @return bool Whether events were logged
*/ */
protected static function logAddedComments( $addedComments, $newRevRecord, $title, $identity ) { protected static function logAddedComments( $addedComments, $newRevRecord, $title, $identity ) {
global $wgDTSchemaEditAttemptStepOversample, $wgDBname; global $wgDTSchemaEditAttemptStepOversample, $wgWMESchemaEditAttemptStepOversample, $wgDBname;
$request = RequestContext::getMain()->getRequest(); $context = RequestContext::getMain();
$request = $context->getRequest();
// We've reached here through Echo's post-save deferredupdate, which // We've reached here through Echo's post-save deferredupdate, which
// might either be after an API request from DiscussionTools or a // might either be after an API request from DiscussionTools or a
// regular POST from WikiEditor. Both should have this value snuck // regular POST from WikiEditor. Both should have this value snuck
@ -357,17 +358,19 @@ class EventDispatcher {
return false; return false;
} }
$editingStatsId = $request->getVal( 'editingStatsId' ); $editingStatsId = $request->getVal( 'editingStatsId' );
$isDiscussionTools = (bool)$request->getVal( 'dttags' );
$extensionRegistry = ExtensionRegistry::getInstance(); $extensionRegistry = ExtensionRegistry::getInstance();
if ( !$extensionRegistry->isLoaded( 'EventLogging' ) ) { if ( !$extensionRegistry->isLoaded( 'EventLogging' ) ) {
return false; return false;
} }
$inSample = self::inEventSample( $editingStatsId ); $inSample = self::inEventSample( $editingStatsId );
$shouldOversample = $wgDTSchemaEditAttemptStepOversample || ( $shouldOversample = $wgWMESchemaEditAttemptStepOversample ||
$extensionRegistry->isLoaded( 'WikimediaEvents' ) && ( $isDiscussionTools && $wgDTSchemaEditAttemptStepOversample ) || (
// @phan-suppress-next-line PhanUndeclaredClassMethod $extensionRegistry->isLoaded( 'WikimediaEvents' ) &&
\WikimediaEvents\WikimediaEventsHooks::shouldSchemaEditAttemptStepOversample( RequestContext::getMain() ) // @phan-suppress-next-line PhanUndeclaredClassMethod
); \WikimediaEvents\WikimediaEventsHooks::shouldSchemaEditAttemptStepOversample( $context )
);
if ( !$inSample && !$shouldOversample ) { if ( !$inSample && !$shouldOversample ) {
return false; return false;
} }
@ -376,8 +379,6 @@ class EventDispatcher {
->getUserFactory() ->getUserFactory()
->newFromUserIdentity( $identity ); ->newFromUserIdentity( $identity );
$isDiscussionTools = (bool)$request->getVal( 'dttags' );
foreach ( $addedComments as $comment ) { foreach ( $addedComments as $comment ) {
$heading = $comment->getSubscribableHeading(); $heading = $comment->getSubscribableHeading();
$parent = $comment->getParent(); $parent = $comment->getParent();
@ -400,7 +401,7 @@ class EventDispatcher {
'user_edit_count' => $user->getEditCount() ?: 0, 'user_edit_count' => $user->getEditCount() ?: 0,
// Retention-safe values: // Retention-safe values:
'user_is_anonymous' => !$user->isRegistered(), 'user_is_anonymous' => !$user->isRegistered(),
'user_edit_count_bucket' => \UserBucketProvider::getUserEditCountBucket( $user ), 'user_edit_count_bucket' => \UserBucketProvider::getUserEditCountBucket( $user ) ?: 'N/A',
], ],
'database' => $wgDBname, 'database' => $wgDBname,
// This is unreliable, but sufficient for our purposes; we // This is unreliable, but sufficient for our purposes; we