X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryCategories.php;h=79347e625a300e5d86d38eac2a188b2ad54eb68d;hb=95797de3d623d5a5f48cf82edf502a2296bdc257;hp=c4428d575a1a845cec7f59d65b5199b7f31c533a;hpb=d5a7166771613dfe4ed9fb75fa5efeced6134bd1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index c4428d575a..79347e625a 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -1,9 +1,5 @@ @gmail.com" * * This program is free software; you can redistribute it and/or modify @@ -69,7 +65,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { $this->addTables( 'categorylinks' ); $this->addWhereFld( 'cl_from', array_keys( $this->getPageSet()->getGoodTitles() ) ); - if ( !is_null( $params['categories'] ) ) { + if ( $params['categories'] ) { $cats = []; foreach ( $params['categories'] as $cat ) { $title = Title::newFromText( $cat ); @@ -79,6 +75,10 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { $cats[] = $title->getDBkey(); } } + if ( !$cats ) { + // No titles so no results + return; + } $this->addWhereFld( 'cl_to', $cats ); } @@ -86,7 +86,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 2 ); $op = $params['dir'] == 'descending' ? '<' : '>'; - $clfrom = intval( $cont[0] ); + $clfrom = (int)$cont[0]; $clto = $this->getDB()->addQuotes( $cont[1] ); $this->addWhere( "cl_from $op $clfrom OR " . @@ -127,6 +127,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { 'cl_to' . $sort ] ); } + $this->addOption( 'LIMIT', $params['limit'] + 1 ); $res = $this->select( __METHOD__ );