X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRandom.php;h=ce62226fc6d074e32e6ad07acee2e776933f007f;hb=64b83bdb3afd0ee4f8fc1893a865409c198e601e;hp=cc1fc89f07618f04b14c587640d9e237e6ba8c4c;hpb=94ad2bf3801eba8767363e22c16212fa084f9a2d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryRandom.php b/includes/api/ApiQueryRandom.php index cc1fc89f07..ce62226fc6 100644 --- a/includes/api/ApiQueryRandom.php +++ b/includes/api/ApiQueryRandom.php @@ -48,7 +48,7 @@ class ApiQueryRandom extends ApiQueryGeneratorBase { * @param ApiPageSet|null $resultPageSet * @param int $limit Number of pages to fetch * @param string|null $start Starting page_random - * @param int|null $startId Starting page_id + * @param int $startId Starting page_id * @param string|null $end Ending page_random * @return array (int, string|null) Number of pages left to query and continuation string */ @@ -75,8 +75,8 @@ class ApiQueryRandom extends ApiQueryGeneratorBase { if ( $start !== null ) { $start = $this->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 +144,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 ) {