X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRandom.php;h=636191d387d2b30ac822053b8f6cc64e81d71c56;hb=1e56f9b78a5ee19ae2aa14436afa6fba7d59c4f9;hp=cc1fc89f07618f04b14c587640d9e237e6ba8c4c;hpb=3cb14f56bdf3271769a5866f9dcaad56bf873aea;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryRandom.php b/includes/api/ApiQueryRandom.php index cc1fc89f07..636191d387 100644 --- a/includes/api/ApiQueryRandom.php +++ b/includes/api/ApiQueryRandom.php @@ -1,10 +1,6 @@ getDB()->addQuotes( $start ); - if ( $startId !== null ) { - $startId = (int)$startId; + if ( $startId > 0 ) { + $startId = (int)$startId; // safety $this->addWhere( "page_random = $start AND page_id >= $startId OR page_random > $start" ); } else { $this->addWhere( "page_random >= $start" ); @@ -144,10 +140,19 @@ class ApiQueryRandom extends ApiQueryGeneratorBase { } else { $rand = wfRandom(); $start = $rand; - $startId = null; + $startId = 0; $end = null; } + // Set the non-continue if this is being used as a generator + // (as a list it doesn't matter because lists never non-continue) + if ( $resultPageSet !== null ) { + $endFlag = $end === null ? 0 : 1; + $this->getContinuationManager()->addGeneratorNonContinueParam( + $this, 'continue', "$rand|$start|$startId|$endFlag" + ); + } + list( $left, $continue ) = $this->runQuery( $resultPageSet, $params['limit'], $start, $startId, $end ); if ( $end === null && $continue === null ) {