Merge "Update for the actor table change"

This commit is contained in:
jenkins-bot 2018-03-17 09:36:59 +00:00 committed by Gerrit Code Review
commit 6d32b24d16
5 changed files with 22 additions and 10 deletions

View file

@ -409,17 +409,19 @@ class AFComputedVariable {
$dbr = wfGetDB( DB_REPLICA );
$setOpts += Database::getCacheSetOptions( $dbr );
// Get the last 100 edit authors with a trivial query (avoid T116557)
$revQuery = Revision::getQueryInfo();
$revAuthors = $dbr->selectFieldValues(
'revision',
'rev_user_text',
$revQuery['tables'],
$revQuery['fields']['rev_user_text'],
[ 'rev_page' => $title->getArticleID() ],
__METHOD__,
// Some pages have < 10 authors but many revisions (e.g. bot pages)
[ 'ORDER BY' => 'rev_timestamp DESC',
'LIMIT' => 100,
// Force index per T116557
'USE INDEX' => 'page_timestamp',
]
'USE INDEX' => [ 'revision' => 'page_timestamp' ],
],
$revQuery['joins']
);
// Get the last 10 distinct authors within this set of edits
$users = [];

View file

@ -384,7 +384,7 @@ class AbuseFilterHooks {
$action = $recentChange->mAttribs['rc_log_type'] ?
$recentChange->mAttribs['rc_log_type'] : 'edit';
$actionID = implode( '-', [
$title->getPrefixedText(), $recentChange->mAttribs['rc_user_text'], $action
$title->getPrefixedText(), $recentChange->getAttribute( 'rc_user_text' ), $action
] );
if ( isset( AbuseFilter::$tagsToSet[$actionID] ) ) {

View file

@ -92,7 +92,12 @@ class AbuseFilterViewTestBatch extends AbuseFilterView {
$dbr = wfGetDB( DB_REPLICA );
$conds = [];
$conds['rc_user_text'] = $this->mTestUser;
if ( (string)$this->mTestUser !== '' ) {
$conds[] = ActorMigration::newMigration()->getWhere(
$dbr, 'rc_user', User::newFromName( $this->mTestUser, false )
)['conds'];
}
if ( $this->mTestPeriodStart ) {
$conds[] = 'rc_timestamp >= ' .

View file

@ -18,7 +18,12 @@ class AbuseFilterExaminePager extends ReverseChronologicalPager {
function getQueryInfo() {
$dbr = wfGetDB( DB_REPLICA );
$conds = [];
$conds['rc_user_text'] = $this->mPage->mSearchUser;
if ( (string)$this->mPage->mSearchUser !== '' ) {
$conds[] = ActorMigration::newMigration()->getWhere(
$dbr, 'rc_user', User::newFromName( $this->mPage->mSearchUser, false )
)['conds'];
}
$startTS = strtotime( $this->mPage->mSearchPeriodStart );
if ( $startTS ) {

View file

@ -72,19 +72,19 @@ class AddMissingLoggingEntries extends Maintenance {
if ( $count % 100 == 0 ) {
wfWaitForSlaves();
}
$user = User::newFromAnyId( $row->afh_user, $row->afh_user_text, null );
$dbw->insert(
'logging',
[
'log_type' => 'abusefilter',
'log_action' => 'modify',
'log_timestamp' => $row->afh_timestamp,
'log_user' => $row->afh_user,
'log_namespace' => -1,
'log_title' => SpecialPageFactory::getLocalNameFor( 'AbuseFilter' ) . '/' . $row->afh_filter,
'log_params' => $row->afh_id . '\n' . $row->afh_filter,
'log_deleted' => $row->afh_deleted,
'log_user_text' => $row->afh_user_text,
] + CommentStore::getStore()->insert( $dbw, 'log_comment', '' ),
] + CommentStore::getStore()->insert( $dbw, 'log_comment', '' )
+ ActorMigration::newMigration()->getInsertValues( $dbw, 'log_user', $user ),
__METHOD__
);
$count++;