From: Sam Reed Date: Sun, 13 Mar 2011 17:36:31 +0000 (+0000) Subject: Cleanup/simplify code added to alllinks in r70584 X-Git-Tag: 1.31.0-rc.0~31457 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=f0dc6ef7bbe0d33d530252d3b64061fc67d1c095;p=lhc%2Fweb%2Fwiklou.git Cleanup/simplify code added to alllinks in r70584 --- diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index ab28cacb93..4b40ffb6de 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -94,12 +94,10 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { ); } - if ( !is_null( $params['from'] ) ) { - $this->addWhere( 'pl_title>=' . $db->addQuotes( $this->titlePartToKey( $params['from'] ) ) ); - } - if ( !is_null( $params['to'] ) ) { - $this->addWhere( 'pl_title<=' . $db->addQuotes( $this->titlePartToKey( $params['to'] ) ) ); - } + $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) ); + $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) ); + $this->addWhereRange( 'pl_title', 'newer', $from, $to ); + if ( isset( $params['prefix'] ) ) { $this->addWhere( 'pl_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } @@ -112,10 +110,9 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $this->addOption( 'USE INDEX', 'pl_namespace' ); $limit = $params['limit']; $this->addOption( 'LIMIT', $limit + 1 ); - if ( $params['unique'] ) { - $this->addOption( 'ORDER BY', 'pl_title' ); - } else { - $this->addOption( 'ORDER BY', 'pl_title, pl_from' ); + + if ( !$params['unique'] ) { + $this->addOption( 'ORDER BY', 'pl_from' ); } $res = $this->select( __METHOD__ );