Bug 27341 - Add drto param to list=deletedrevs
[lhc/web/wiklou.git] / includes / api / ApiQueryAllLinks.php
index cb62438..4b40ffb 100644 (file)
@@ -1,9 +1,8 @@
 <?php
-
 /**
- * Created on July 7, 2007
  *
- * API for MediaWiki 1.8+
+ *
+ * Created on July 7, 2007
  *
  * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
@@ -21,6 +20,8 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -51,6 +52,10 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                $this->run( $resultPageSet );
        }
 
+       /**
+        * @param $resultPageSet ApiPageSet
+        * @return void
+        */
        private function run( $resultPageSet = null ) {
                $db = $this->getDB();
                $params = $this->extractRequestParams();
@@ -89,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() ) );
                }
@@ -107,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__ );
@@ -223,7 +225,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
 
        protected function getExamples() {
                return array(
-                       'api.php?action=query&list=alllinks&alunique&alfrom=B',
+                       'api.php?action=query&list=alllinks&alunique=&alfrom=B',
                );
        }