X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPagesWithProp.php;h=670a3973b9b8347fa129c260c2bbd060dde9085e;hp=05f0b2b1f4bd6ee2479a9c1067c1c3a271a82b28;hb=b51076a84446d157bed511246450e70d26e0f945;hpb=ec56b68a23755682a76b7a6d634ca914b1b08b83 diff --git a/includes/specials/SpecialPagesWithProp.php b/includes/specials/SpecialPagesWithProp.php index 05f0b2b1f4..670a3973b9 100644 --- a/includes/specials/SpecialPagesWithProp.php +++ b/includes/specials/SpecialPagesWithProp.php @@ -82,12 +82,14 @@ class SpecialPagesWithProp extends QueryPage { * Return an array of subpages beginning with $search that this special page will accept. * * @param string $search Prefix to search for - * @param integer $limit Maximum number of results to return + * @param int $limit Maximum number of results to return + * @param int $offset Number of pages to skip * @return string[] Matching subpages */ - public function prefixSearchSubpages( $search, $limit = 10 ) { - $subpages = array_keys( $this->getExistingPropNames() ); - return self::prefixSearchArray( $search, $limit, $subpages ); + public function prefixSearchSubpages( $search, $limit, $offset ) { + $subpages = array_keys( $this->queryExistingProps( $limit, $offset ) ); + // We've already limited and offsetted, set to N and 0 respectively. + return self::prefixSearchArray( $search, count( $subpages ), $subpages, 0 ); } /** @@ -154,23 +156,38 @@ class SpecialPagesWithProp extends QueryPage { public function getExistingPropNames() { if ( $this->existingPropNames === null ) { - $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( - 'page_props', - 'pp_propname', - '', - __METHOD__, - array( 'DISTINCT', 'ORDER BY' => 'pp_propname' ) - ); - $propnames = array(); - foreach ( $res as $row ) { - $propnames[$row->pp_propname] = $row->pp_propname; - } - $this->existingPropNames = $propnames; + $this->existingPropNames = $this->queryExistingProps(); } return $this->existingPropNames; } + protected function queryExistingProps( $limit = null, $offset = 0 ) { + $opts = array( + 'DISTINCT', 'ORDER BY' => 'pp_propname' + ); + if ( $limit ) { + $opts['LIMIT'] = $limit; + } + if ( $offset ) { + $opts['OFFSET'] = $offset; + } + + $res = wfGetDB( DB_SLAVE )->select( + 'page_props', + 'pp_propname', + '', + __METHOD__, + $opts + ); + + $propnames = array(); + foreach ( $res as $row ) { + $propnames[$row->pp_propname] = $row->pp_propname; + } + + return $propnames; + } + protected function getGroupName() { return 'pages'; }