X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryBase.php;h=59e665209e1bbd6b1af5819d363e4c6be3e85690;hb=62a6a48bd4cde140a2bebde73f882754dfaa273b;hp=2a8645f62d011421ce862536e1a0bffe0de2e43f;hpb=a8c4507f6f7094dcecab6cd08e72e53af308b64d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 2a8645f62d..59e665209e 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -351,7 +351,7 @@ abstract class ApiQueryBase extends ApiBase { } $result = $this->getResult(); $fit = $result->addValue( array( 'query', 'pages', $pageId, - $this->getModuleName() ), null, $item ); + $this->getModuleName() ), null, $item ); if ( !$fit ) { return false; } @@ -393,8 +393,7 @@ abstract class ApiQueryBase extends ApiBase { */ protected function getDB() { if ( is_null( $this->mDb ) ) { - $apiQuery = $this->getQuery(); - $this->mDb = $apiQuery->getDB(); + $this->mDb = $this->getQuery()->getDB(); } return $this->mDb; } @@ -585,24 +584,32 @@ abstract class ApiQueryBase extends ApiBase { */ abstract class ApiQueryGeneratorBase extends ApiQueryBase { - private $mIsGenerator; + private $mGeneratorPageSet = null; /** - * @param $query ApiBase - * @param $moduleName string - * @param $paramPrefix string + * Switch this module to generator mode. By default, generator mode is + * switched off and the module acts like a normal query module. + * @since 1.21 requires pageset parameter + * @param $generatorPageSet ApiPageSet object that the module will get + * by calling getPageSet() when in generator mode. */ - public function __construct( $query, $moduleName, $paramPrefix = '' ) { - parent::__construct( $query, $moduleName, $paramPrefix ); - $this->mIsGenerator = false; + public function setGeneratorMode( ApiPageSet $generatorPageSet ) { + if ( $generatorPageSet === null ) { + ApiBase::dieDebug( __METHOD__, 'Required parameter missing - $generatorPageSet' ); + } + $this->mGeneratorPageSet = $generatorPageSet; } /** - * Switch this module to generator mode. By default, generator mode is - * switched off and the module acts like a normal query module. + * Get the PageSet object to work on. + * If this module is generator, the pageSet object is different from other module's + * @return ApiPageSet */ - public function setGeneratorMode() { - $this->mIsGenerator = true; + protected function getPageSet() { + if ( $this->mGeneratorPageSet !== null ) { + return $this->mGeneratorPageSet; + } + return parent::getPageSet(); } /** @@ -611,7 +618,7 @@ abstract class ApiQueryGeneratorBase extends ApiQueryBase { * @return string Prefixed parameter name */ public function encodeParamName( $paramName ) { - if ( $this->mIsGenerator ) { + if ( $this->mGeneratorPageSet !== null ) { return 'g' . parent::encodeParamName( $paramName ); } else { return parent::encodeParamName( $paramName );