bug 2429 fix up index by using IN / NOT IN instead of (!= and !=)
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 13 May 2011 15:56:12 +0000 (15:56 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 13 May 2011 15:56:12 +0000 (15:56 +0000)
Tested (EXPLAIN <query>) against the english wikipedia database.

Follow up:
- r83110 : original ns association implementation
- r87992 : abstraction support for 'NOT IN'

(note: breaks some existing PHPUnit tests)

includes/specials/SpecialRecentchanges.php

index 0906715..5840917 100644 (file)
@@ -316,25 +316,24 @@ class SpecialRecentChanges extends IncludableSpecialPage {
 
                # Namespace filtering
                if( $opts['namespace'] !== '' ) {
-                       $selectedNS = $dbr->addQuotes( $opts['namespace'] );
-                       $operator = $opts['invert'] ? '!='  : '=';
-                       $boolean  = $opts['invert'] ? 'AND' : 'OR';
+                       $namespaces[] = $opts['namespace'];
 
-                       # namespace association (bug 2429)
-                       if( !$opts['associated'] ) {
-                               $condition = "rc_namespace $operator $selectedNS";
-                       } else {
-                               # Also add the associated namespace
-                               $associatedNS = $dbr->addQuotes(
-                                       MWNamespace::getAssociated( $opts['namespace'] )
-                               );
-                               $condition = "(rc_namespace $operator $selectedNS "
-                                                  . $boolean
-                                                  . " rc_namespace $operator $associatedNS)";
+                       $inversionSuffix = $opts['invert'] ? '!' : '';
+                       
+                       if( $opts['associated'] ) {
+                               # namespace association (bug 2429)
+                               $namespaces[] = MWNamespace::getAssociated( $opts['namespace'] );
                        }
 
+                       $condition = $dbr->makeList(
+                               array( 'rc_namespace' . $inversionSuffix
+                                       => $namespaces ),
+                               LIST_AND
+                       );
+
                        $conds[] = $condition;
                }
+
                return $conds;
        }