r96543 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96542‎ | r96543 | r96544 >
Date:08:46, 8 September 2011
Author:nikerabbit
Status:resolved (Comments)
Tags:
Comment:
Change LogEventsList to use query info from DatabaseLogEntry.
The only changes in the query are:
* New fields: log_user_text, user_id
* INNER JOIN on user table is changed to LEFT JOIN
* AND (user_id = log_user) is dropped from WHERE conditions (looks redundant, easy to add back if needed)

This means that log entries from anonymous users are not dropped anymore.
Those will actually get displayed correctly after the next commit.
It is also possible to use User::newFromRow for non-anonymous users now.
Modified paths:
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LogEventsList.php
@@ -979,11 +979,21 @@
980980 }
981981 }
982982
 983+ /**
 984+ * Constructs the most part of the query. Extra conditions are sprinkled in
 985+ * all over this class.
 986+ * @return array
 987+ */
983988 public function getQueryInfo() {
984 - $tables = array( 'logging', 'user' );
985 - $this->mConds[] = 'user_id = log_user';
 989+ $basic = DatabaseLogEntry::getSelectQueryData();
 990+
 991+ $tables = $basic['tables'];
 992+ $fields = $basic['fields'];
 993+ $conds = $basic['conds'];
 994+ $options = $basic['options'];
 995+ $joins = $basic['join_conds'];
 996+
986997 $index = array();
987 - $options = array();
988998 # Add log_search table if there are conditions on it.
989999 # This filters the results to only include log rows that have
9901000 # log_search records with the specified ls_field and ls_value values.
@@ -1014,17 +1024,14 @@
10151025 }
10161026 $options['USE INDEX'] = $index;
10171027 # Don't show duplicate rows when using log_search
 1028+ $joins['log_search'] = array( 'INNER JOIN', 'ls_log_id=log_id' );
 1029+
10181030 $info = array(
10191031 'tables' => $tables,
1020 - 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace',
1021 - 'log_title', 'log_params', 'log_comment', 'log_id', 'log_deleted',
1022 - 'log_timestamp', 'user_name', 'user_editcount' ),
1023 - 'conds' => $this->mConds,
 1032+ 'fields' => $fields,
 1033+ 'conds' => $conds + $this->mConds,
10241034 'options' => $options,
1025 - 'join_conds' => array(
1026 - 'user' => array( 'INNER JOIN', 'user_id=log_user' ),
1027 - 'log_search' => array( 'INNER JOIN', 'ls_log_id=log_id' )
1028 - )
 1035+ 'join_conds' => $joins,
10291036 );
10301037 # Add ChangeTags filter query
10311038 ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'],

Follow-up revisions

RevisionCommit summaryAuthorDate
r96647Followup r96543, + is not the correct thing to use herenikerabbit05:17, 9 September 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   22:08, 8 September 2011
'conds'      => $conds + $this->mConds,

Can you use array_merge() here instead?

#Comment by 😂 (talk | contribs)   00:53, 9 September 2011

Wouldn't you want key replacement for this?

#Comment by Aaron Schulz (talk | contribs)   22:21, 8 September 2011

Status & tagging log