aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2024-03-15 22:42:08 +0100
committerUmherirrender <umherirrender_de.wp@web.de>2024-04-30 16:39:34 +0000
commite0c58ab4c9e7f9ec3945f078d5449652c855e2b0 (patch)
tree47615f303198a231d1ac3d8577a2646a814899f6
parent4ae621cb8f7f1a72275fe60c5a06a97524f9d4ad (diff)
downloadmediawikicore-e0c58ab4c9e7f9ec3945f078d5449652c855e2b0.tar.gz
mediawikicore-e0c58ab4c9e7f9ec3945f078d5449652c855e2b0.zip
api: Join actor conditionally on list=logevents
When nothing is used from actor, do not add it to the query Change-Id: I7b0095befd4403395a0bf7c0958adbbefa229020
-rw-r--r--includes/api/ApiQueryLogEvents.php25
1 files changed, 14 insertions, 11 deletions
diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php
index 0630dc738478..07a5ff6457f8 100644
--- a/includes/api/ApiQueryLogEvents.php
+++ b/includes/api/ApiQueryLogEvents.php
@@ -107,10 +107,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
$this->addWhere( $hideLogs );
}
- $this->addTables( [ 'logging', 'actor' ] );
- $this->addJoinConds( [
- 'actor' => [ 'JOIN', 'actor_id=log_actor' ],
- ] );
+ $this->addTables( 'logging' );
$this->addFields( [
'log_id',
@@ -120,6 +117,19 @@ class ApiQueryLogEvents extends ApiQueryBase {
'log_deleted',
] );
+ $user = $params['user'];
+ if ( $this->fld_user || $this->fld_userid || $user !== null ) {
+ $this->addTables( 'actor' );
+ $this->addJoinConds( [
+ 'actor' => [ 'JOIN', 'actor_id=log_actor' ],
+ ] );
+ $this->addFieldsIf( [ 'actor_name', 'actor_user' ], $this->fld_user );
+ $this->addFieldsIf( 'actor_user', $this->fld_userid );
+ if ( $user !== null ) {
+ $this->addWhereFld( 'actor_name', $user );
+ }
+ }
+
if ( $this->fld_ids ) {
$this->addTables( 'page' );
$this->addJoinConds( [
@@ -132,8 +142,6 @@ class ApiQueryLogEvents extends ApiQueryBase {
// scenarios, e.g. deletion, recreation.
$this->addFields( [ 'page_id', 'log_page' ] );
}
- $this->addFieldsIf( [ 'actor_name', 'actor_user' ], $this->fld_user );
- $this->addFieldsIf( 'actor_user', $this->fld_userid );
$this->addFieldsIf(
[ 'log_namespace', 'log_title' ],
$this->fld_title || $this->fld_parsedcomment
@@ -213,11 +221,6 @@ class ApiQueryLogEvents extends ApiQueryBase {
$limit = $params['limit'];
$this->addOption( 'LIMIT', $limit + 1 );
- $user = $params['user'];
- if ( $user !== null ) {
- $this->addWhereFld( 'actor_name', $user );
- }
-
$title = $params['title'];
if ( $title !== null ) {
$titleObj = Title::newFromText( $title );