pager: Simplify namespace condition from pagers
Use expression builder to use IN() or NOT IN() when the associated namespace is also part of the condition. old: (rc_namespace != 0 AND rc_namespace != 1) new: (rc_namespace NOT IN (0,1)) Change-Id: I8bec03812607d61894594081c1be9e6f69f478d7
This commit is contained in:
parent
2ce1021941
commit
02256a060c
2 changed files with 8 additions and 26 deletions
|
|
@ -422,21 +422,12 @@ abstract class ContributionsPager extends RangeChronologicalPager {
|
|||
protected function getNamespaceCond() {
|
||||
if ( $this->namespace !== '' ) {
|
||||
$dbr = $this->getDatabase();
|
||||
$selectedNS = $dbr->addQuotes( $this->namespace );
|
||||
$namespaces = [ $this->namespace ];
|
||||
$eq_op = $this->nsInvert ? '!=' : '=';
|
||||
$bool_op = $this->nsInvert ? 'AND' : 'OR';
|
||||
|
||||
if ( !$this->associated ) {
|
||||
return [ $this->pageNamespaceField . " $eq_op $selectedNS" ];
|
||||
if ( $this->associated ) {
|
||||
$namespaces[] = $this->namespaceInfo->getAssociated( $this->namespace );
|
||||
}
|
||||
|
||||
$associatedNS = $dbr->addQuotes( $this->namespaceInfo->getAssociated( $this->namespace ) );
|
||||
|
||||
return [
|
||||
$this->pageNamespaceField . " $eq_op $selectedNS " .
|
||||
$bool_op .
|
||||
" " . $this->pageNamespaceField . " $eq_op $associatedNS"
|
||||
];
|
||||
return [ $dbr->expr( $this->pageNamespaceField, $eq_op, $namespaces ) ];
|
||||
}
|
||||
|
||||
return [];
|
||||
|
|
|
|||
|
|
@ -204,22 +204,13 @@ class NewPagesPager extends ReverseChronologicalPager {
|
|||
$associated = $this->opts->getValue( 'associated' );
|
||||
|
||||
$eq_op = $invert ? '!=' : '=';
|
||||
$bool_op = $invert ? 'AND' : 'OR';
|
||||
|
||||
$dbr = $this->getDatabase();
|
||||
$selectedNS = $dbr->addQuotes( $namespace );
|
||||
if ( !$associated ) {
|
||||
return [ "rc_namespace $eq_op $selectedNS" ];
|
||||
$namespaces = [ $namespace ];
|
||||
if ( $associated ) {
|
||||
$namespaces[] = $this->namespaceInfo->getAssociated( $namespace );
|
||||
}
|
||||
|
||||
$associatedNS = $dbr->addQuotes(
|
||||
$this->namespaceInfo->getAssociated( $namespace )
|
||||
);
|
||||
return [
|
||||
"rc_namespace $eq_op $selectedNS " .
|
||||
$bool_op .
|
||||
" rc_namespace $eq_op $associatedNS"
|
||||
];
|
||||
return [ $dbr->expr( 'rc_namespace', $eq_op, $namespaces ) ];
|
||||
}
|
||||
|
||||
public function getIndexField() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue