From: umherirrender Date: Fri, 30 Mar 2012 21:19:34 +0000 (+0200) Subject: (bug 26909) follow up r102947: fix the navigation with 'dir' X-Git-Tag: 1.31.0-rc.0~23910^2 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=1b41425ee4c7cbae0f90b21f1ef8f4b93c9b0f4a;p=lhc%2Fweb%2Fwiklou.git (bug 26909) follow up r102947: fix the navigation with 'dir' 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 --- diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index 1c1f1550df..243d1acf12 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -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)" ); } diff --git a/includes/api/ApiQueryDuplicateFiles.php b/includes/api/ApiQueryDuplicateFiles.php index beca587915..0132d67c5d 100644 --- a/includes/api/ApiQueryDuplicateFiles.php +++ b/includes/api/ApiQueryDuplicateFiles.php @@ -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__ ); diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 13256ad89f..bc42fe0fa8 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -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)))" ); } diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php index f03b287440..64d7ff42ce 100644 --- a/includes/api/ApiQueryImages.php +++ b/includes/api/ApiQueryImages.php @@ -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)" ); } diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index fdba8465e3..d505d726f1 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -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)" ); } diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 0377eddb50..6e6da53d34 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -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)))" ); }