raise timeout for CdbTest::testCdb()
[lhc/web/wiklou.git] / includes / api / ApiQueryAllPages.php
index dec3d8a..0c6692a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Created on Sep 25, 2006
  *
- * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -67,6 +67,14 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                // Page filters
                $this->addTables( 'page' );
 
+               if ( !is_null( $params['continue'] ) ) {
+                       $cont = explode( '|', $params['continue'] );
+                       $this->dieContinueUsageIf( count( $cont ) != 1 );
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
+                       $cont_from = $db->addQuotes( $cont[0] );
+                       $this->addWhere( "page_title $op= $cont_from" );
+               }
+
                if ( $params['filterredir'] == 'redirects' ) {
                        $this->addWhereFld( 'page_is_redirect', 1 );
                } elseif ( $params['filterredir'] == 'nonredirects' ) {
@@ -180,8 +188,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                foreach ( $res as $row ) {
                        if ( ++ $count > $limit ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
-                               // TODO: Security issue - if the user has no right to view next title, it will still be shown
-                               $this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->page_title ) );
+                               $this->setContinueEnumParameter( 'continue', $row->page_title );
                                break;
                        }
 
@@ -194,7 +201,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                                );
                                $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
                                if ( !$fit ) {
-                                       $this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->page_title ) );
+                                       $this->setContinueEnumParameter( 'continue', $row->page_title );
                                        break;
                                }
                        } else {
@@ -212,10 +219,11 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
 
                return array(
                        'from' => null,
+                       'continue' => null,
                        'to' => null,
                        'prefix' => null,
                        'namespace' => array(
-                               ApiBase::PARAM_DFLT => 0,
+                               ApiBase::PARAM_DFLT => NS_MAIN,
                                ApiBase::PARAM_TYPE => 'namespace',
                        ),
                        'filterredir' => array(
@@ -285,6 +293,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                $p = $this->getModulePrefix();
                return array(
                        'from' => 'The page title to start enumerating from',
+                       'continue' => 'When more results are available, use this to continue',
                        'to' => 'The page title to stop enumerating at',
                        'prefix' => 'Search for all page titles that begin with this value',
                        'namespace' => 'The namespace to enumerate',
@@ -346,8 +355,4 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
        public function getHelpUrls() {
                return 'https://www.mediawiki.org/wiki/API:Allpages';
        }
-
-       public function getVersion() {
-               return __CLASS__ . ': $Id$';
-       }
 }