(bug 26909) follow up r102947: fix the navigation with 'dir'
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 30 Mar 2012 21:19:34 +0000 (23:19 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 30 Mar 2012 21:19:34 +0000 (23:19 +0200)
and 'continue' for some prop-Modules

Due to missing change of the where for the query-continue in my first
patch, using dir=descending will end up in a loop

Change-Id: I6a9ade9feddcfd046de347cd83a756af828b5c18

includes/api/ApiQueryCategories.php
includes/api/ApiQueryDuplicateFiles.php
includes/api/ApiQueryIWLinks.php
includes/api/ApiQueryImages.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQueryLinks.php

index 1c1f155..243d1ac 100644 (file)
@@ -89,12 +89,13 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
                                $this->dieUsage( "Invalid continue param. You should pass the " .
                                        "original value returned by the previous query", "_badcontinue" );
                        }
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
                        $clfrom = intval( $cont[0] );
-                       $clto = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
+                       $clto = $this->getDB()->addQuotes( $this->titleToKey( $cont[1] ) );
                        $this->addWhere(
-                               "cl_from > $clfrom OR " .
+                               "cl_from $op $clfrom OR " .
                                "(cl_from = $clfrom AND " .
-                               "cl_to >= '$clto')"
+                               "cl_to $op= $clto)"
                        );
                }
 
index beca587..0132d67 100644 (file)
@@ -80,17 +80,27 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase {
                                $this->dieUsage( 'Invalid continue param. You should pass the ' .
                                        'original value returned by the previous query', '_badcontinue' );
                        }
-                       $orig = $this->getDB()->strencode( $this->titleTokey( $cont[0] ) );
-                       $dup = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
+                       $db = $this->getDB();
+                       $orig = $db->addQuotes( $this->titleTokey( $cont[0] ) );
+                       $dup = $db->addQuotes( $this->titleToKey( $cont[1] ) );
                        $this->addWhere(
-                               "i1.img_name > '$orig' OR " .
-                               "(i1.img_name = '$orig' AND " .
-                               "i2.img_name >= '$dup')"
+                               "i1.img_name $op $orig OR " .
+                               "(i1.img_name = $orig AND " .
+                               "i2.img_name $op= $dup)"
                        );
                }
 
                $dir = ( $params['dir'] == 'descending' ? ' DESC' : '' );
-               $this->addOption( 'ORDER BY', 'i1.img_name' . $dir );
+               // Don't order by i1.img_name if it's constant in the WHERE clause
+               if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
+                       $this->addOption( 'ORDER BY', 'i2.img_name' . $dir );
+               } else {
+                       $this->addOption( 'ORDER BY', array(
+                                       'i1.img_name' . $dir,
+                                       'i2.img_name' . $dir
+                       ));
+               }
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
                $res = $this->select( __METHOD__ );
index 13256ad..bc42fe0 100644 (file)
@@ -62,15 +62,17 @@ class ApiQueryIWLinks extends ApiQueryBase {
                                $this->dieUsage( 'Invalid continue param. You should pass the ' .
                                        'original value returned by the previous query', '_badcontinue' );
                        }
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
+                       $db = $this->getDB();
                        $iwlfrom = intval( $cont[0] );
-                       $iwlprefix = $this->getDB()->strencode( $cont[1] );
-                       $iwltitle = $this->getDB()->strencode( $this->titleToKey( $cont[2] ) );
+                       $iwlprefix = $db->addQuotes( $cont[1] );
+                       $iwltitle = $db->addQuotes( $this->titleToKey( $cont[2] ) );
                        $this->addWhere(
-                               "iwl_from > $iwlfrom OR " .
+                               "iwl_from $op $iwlfrom OR " .
                                "(iwl_from = $iwlfrom AND " .
-                               "(iwl_prefix > '$iwlprefix' OR " .
-                               "(iwl_prefix = '$iwlprefix' AND " .
-                               "iwl_title >= '$iwltitle')))"
+                               "(iwl_prefix $op $iwlprefix OR " .
+                               "(iwl_prefix = $iwlprefix AND " .
+                               "iwl_title $op= $iwltitle)))"
                        );
                }
 
index f03b287..64d7ff4 100644 (file)
@@ -65,12 +65,13 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                                $this->dieUsage( 'Invalid continue param. You should pass the ' .
                                        'original value returned by the previous query', '_badcontinue' );
                        }
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
                        $ilfrom = intval( $cont[0] );
-                       $ilto = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
+                       $ilto = $this->getDB()->addQuotes( $this->titleToKey( $cont[1] ) );
                        $this->addWhere(
-                               "il_from > $ilfrom OR " .
+                               "il_from $op $ilfrom OR " .
                                "(il_from = $ilfrom AND " .
-                               "il_to >= '$ilto')"
+                               "il_to $op= $ilto)"
                        );
                }
 
index fdba846..d505d72 100644 (file)
@@ -60,12 +60,13 @@ class ApiQueryLangLinks extends ApiQueryBase {
                                $this->dieUsage( 'Invalid continue param. You should pass the ' .
                                        'original value returned by the previous query', '_badcontinue' );
                        }
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
                        $llfrom = intval( $cont[0] );
-                       $lllang = $this->getDB()->strencode( $cont[1] );
+                       $lllang = $this->getDB()->addQuotes( $cont[1] );
                        $this->addWhere(
-                               "ll_from > $llfrom OR " .
+                               "ll_from $op $llfrom OR " .
                                "(ll_from = $llfrom AND " .
-                               "ll_lang >= '$lllang')"
+                               "ll_lang $op= $lllang)"
                        );
                }
 
index 0377edd..6e6da53 100644 (file)
@@ -116,15 +116,16 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                                $this->dieUsage( 'Invalid continue param. You should pass the ' .
                                        'original value returned by the previous query', '_badcontinue' );
                        }
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
                        $plfrom = intval( $cont[0] );
                        $plns = intval( $cont[1] );
-                       $pltitle = $this->getDB()->strencode( $this->titleToKey( $cont[2] ) );
+                       $pltitle = $this->getDB()->addQuotes( $this->titleToKey( $cont[2] ) );
                        $this->addWhere(
-                               "{$this->prefix}_from > $plfrom OR " .
+                               "{$this->prefix}_from $op $plfrom OR " .
                                "({$this->prefix}_from = $plfrom AND " .
-                               "({$this->prefix}_namespace > $plns OR " .
+                               "({$this->prefix}_namespace $op $plns OR " .
                                "({$this->prefix}_namespace = $plns AND " .
-                               "{$this->prefix}_title >= '$pltitle')))"
+                               "{$this->prefix}_title $op= $pltitle)))"
                        );
                }