X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fapi%2FApiQueryLogEvents.php;h=84e12d7dfadc295c94ddb338ba8f4f10967048c4;hb=8b45d6c33499eff07d8e0f0807dbfac78657995d;hp=3066720d1cd2bc1280b13fc5e9c8f43ecb5aae38;hpb=d84c3dde5af90c5c3497d18e427a5c2a38ac6ca8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index 3066720d1c..84e12d7dfa 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -1,9 +1,5 @@ @gmail.com" * * This program is free software; you can redistribute it and/or modify @@ -45,7 +41,7 @@ class ApiQueryLogEvents extends ApiQueryBase { public function execute() { $params = $this->extractRequestParams(); $db = $this->getDB(); - $this->commentStore = new CommentStore( 'log_comment' ); + $this->commentStore = CommentStore::getStore(); $this->requireMaxOneParameter( $params, 'title', 'prefix', 'namespace' ); $prop = array_flip( $params['prop'] ); @@ -66,11 +62,15 @@ class ApiQueryLogEvents extends ApiQueryBase { $this->addWhere( $hideLogs ); } - // Order is significant here - $this->addTables( [ 'logging', 'user', 'page' ] ); + $actorMigration = ActorMigration::newMigration(); + $actorQuery = $actorMigration->getJoin( 'log_user' ); + $this->addTables( 'logging' ); + $this->addTables( $actorQuery['tables'] ); + $this->addTables( [ 'user', 'page' ] ); + $this->addJoinConds( $actorQuery['joins'] ); $this->addJoinConds( [ 'user' => [ 'LEFT JOIN', - 'user_id=log_user' ], + 'user_id=' . $actorQuery['fields']['log_user'] ], 'page' => [ 'LEFT JOIN', [ 'log_namespace=page_namespace', 'log_title=page_title' ] ] ] ); @@ -88,8 +88,8 @@ class ApiQueryLogEvents extends ApiQueryBase { // join at query time. This leads to different results in various // scenarios, e.g. deletion, recreation. $this->addFieldsIf( 'log_page', $this->fld_ids ); - $this->addFieldsIf( [ 'log_user', 'log_user_text', 'user_name' ], $this->fld_user ); - $this->addFieldsIf( 'log_user', $this->fld_userid ); + $this->addFieldsIf( $actorQuery['fields'] + [ 'user_name' ], $this->fld_user ); + $this->addFieldsIf( $actorQuery['fields'], $this->fld_userid ); $this->addFieldsIf( [ 'log_namespace', 'log_title' ], $this->fld_title || $this->fld_parsedcomment @@ -97,7 +97,7 @@ class ApiQueryLogEvents extends ApiQueryBase { $this->addFieldsIf( 'log_params', $this->fld_details ); if ( $this->fld_comment || $this->fld_parsedcomment ) { - $commentQuery = $this->commentStore->getJoin(); + $commentQuery = $this->commentStore->getJoin( 'log_comment' ); $this->addTables( $commentQuery['tables'] ); $this->addFields( $commentQuery['fields'] ); $this->addJoinConds( $commentQuery['joins'] ); @@ -170,12 +170,12 @@ class ApiQueryLogEvents extends ApiQueryBase { $user = $params['user']; if ( !is_null( $user ) ) { - $userid = User::idFromName( $user ); - if ( $userid ) { - $this->addWhereFld( 'log_user', $userid ); - } else { - $this->addWhereFld( 'log_user_text', $user ); - } + // Note the joins in $q are the same as those from ->getJoin() above + // so we only need to add 'conds' here. + $q = $actorMigration->getWhere( + $db, 'log_user', User::newFromName( $params['user'], false ) + ); + $this->addWhere( $q['conds'] ); } $title = $params['title']; @@ -342,7 +342,7 @@ class ApiQueryLogEvents extends ApiQueryBase { $anyHidden = true; } if ( LogEventsList::userCan( $row, LogPage::DELETED_COMMENT, $user ) ) { - $comment = $this->commentStore->getComment( $row )->text; + $comment = $this->commentStore->getComment( 'log_comment', $row )->text; if ( $this->fld_comment ) { $vals['comment'] = $comment; }