r59537 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59536‎ | r59537 | r59538 >
Date:00:01, 29 November 2009
Author:aaron
Status:reverted
Tags:
Comment:
* Made log_user_type_time index available when needed
* Don't allow type,time index when 2+ types are given
* Make sure $this->types becomes an array in limitType() ('' -> array() case was left out)
* A few code style tweaks
Modified paths:
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LogEventsList.php
@@ -790,10 +790,13 @@
791791 $types = ($types === '') ? array() : (array)$types;
792792 // Don't even show header for private logs; don't recognize it...
793793 foreach ( $types as $type ) {
794 - if( isset( $wgLogRestrictions[$type] ) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
 794+ if( isset( $wgLogRestrictions[$type] )
 795+ && !$wgUser->isAllowed($wgLogRestrictions[$type])
 796+ ) {
795797 $types = array_diff( $types, array( $type ) );
796798 }
797799 }
 800+ $this->types = $types;
798801 // Don't show private logs to unprivileged users.
799802 // Also, only show them upon specific request to avoid suprises.
800803 $audience = $types ? 'user' : 'public';
@@ -802,7 +805,6 @@
803806 $this->mConds[] = $hideLogs;
804807 }
805808 if( count($types) ) {
806 - $this->types = $types;
807809 $this->mConds['log_type'] = $types;
808810 // Set typeCGI; used in url param for paging
809811 if( count($types) == 1 ) $this->typeCGI = $types[0];
@@ -890,18 +892,25 @@
891893 $tables = array( 'logging', 'user' );
892894 $this->mConds[] = 'user_id = log_user';
893895 $groupBy = false;
 896+ $index = array();
894897 # Add log_search table if there are conditions on it
895898 if( array_key_exists('ls_field',$this->mConds) ) {
896899 $tables[] = 'log_search';
897 - $index = array( 'log_search' => 'ls_field_val', 'logging' => 'PRIMARY' );
 900+ $index['log_search'] = 'ls_field_val';
 901+ $index['logging'] = 'PRIMARY';
898902 $groupBy = 'ls_log_id';
899 - # Don't use the wrong logging index
 903+ # Avoid usage of the wrong index by limiting
 904+ # the choices of available indexes. This mainly
 905+ # avoids site-breaking filesorts.
900906 } else if( $this->title || $this->pattern || $this->user ) {
901 - $index = array( 'logging' => array('page_time','user_time') );
902 - } else if( $this->types ) {
903 - $index = array( 'logging' => 'type_time' );
 907+ $index['logging'] = array( 'page_time', 'user_time' );
 908+ if( count($this->types) == 1 ) {
 909+ $index['logging'][] = array( 'log_user_type_time' );
 910+ }
 911+ } else if( count($this->types) == 1 ) {
 912+ $index['logging'] = 'type_time';
904913 } else {
905 - $index = array( 'logging' => 'times' );
 914+ $index['logging'] = 'times';
906915 }
907916 $options = array( 'USE INDEX' => $index );
908917 # Don't show duplicate rows when using log_search

Follow-up revisions

RevisionCommit summaryAuthorDate
r59543Revert r59537. Breaks page deletion with "PHP Notice: Array to string conver...siebrand10:49, 29 November 2009
r59549Restored r59537 - fixed silly typoaaron16:39, 29 November 2009

Status & tagging log