# 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;
}