X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fapi%2FApiContinuationManager.php;h=19e2453944b132a695a80400b4e525d65d3dfc0d;hb=ea42d90053b36cef47f318a1d50c18dfafc6b7b8;hp=8f1bd1919149a26f42a555c59c27a8b5d382c9e9;hpb=47b93ded1388ce5712d0a816db4ddd3466609bcd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiContinuationManager.php b/includes/api/ApiContinuationManager.php index 8f1bd19191..19e2453944 100644 --- a/includes/api/ApiContinuationManager.php +++ b/includes/api/ApiContinuationManager.php @@ -31,6 +31,7 @@ class ApiContinuationManager { private $continuationData = []; private $generatorContinuationData = []; + private $generatorNonContinuationData = []; private $generatorParams = []; private $generatorDone = false; @@ -142,6 +143,26 @@ class ApiContinuationManager { $this->continuationData[$name][$paramName] = $paramValue; } + /** + * Set the non-continuation parameter for the generator module + * + * In case the generator isn't going to be continued, this sets the fields + * to return. + * + * @since 1.28 + * @param ApiBase $module + * @param string $paramName + * @param string|array $paramValue + */ + public function addGeneratorNonContinueParam( ApiBase $module, $paramName, $paramValue ) { + $name = $module->getModuleName(); + $paramName = $module->encodeParamName( $paramName ); + if ( is_array( $paramValue ) ) { + $paramValue = implode( '|', $paramValue ); + } + $this->generatorNonContinuationData[$name][$paramName] = $paramValue; + } + /** * Set the continuation parameter for the generator module * @param ApiBase $module @@ -165,9 +186,18 @@ class ApiContinuationManager { return array_merge_recursive( $this->continuationData, $this->generatorContinuationData ); } + /** + * Fetch raw non-continuation data + * @since 1.28 + * @return array + */ + public function getRawNonContinuation() { + return $this->generatorNonContinuationData; + } + /** * Fetch continuation result data - * @return array Array( (array)$data, (bool)$batchcomplete ) + * @return array [ (array)$data, (bool)$batchcomplete ] */ public function getContinuation() { $data = []; @@ -192,8 +222,13 @@ class ApiContinuationManager { foreach ( $continuationData as $module => $kvp ) { $data += $kvp; } - $data += $this->generatorParams; - $generatorKeys = implode( '|', array_keys( $this->generatorParams ) ); + $generatorParams = []; + foreach ( $this->generatorNonContinuationData as $kvp ) { + $generatorParams += $kvp; + } + $generatorParams += $this->generatorParams; + $data += $generatorParams; + $generatorKeys = implode( '|', array_keys( $generatorParams ) ); } elseif ( $this->generatorContinuationData ) { // All the generator-using modules are complete, but the // generator isn't. Continue the generator and restart the