- if(!is_null($this->continueStr))
- $this->setContinueEnumParameter('continue', $this->continueStr);
-
- if (is_null($resultPageSet)) {
- $resultData = array();
- foreach($this->data as $ns => $a)
- foreach($a as $title => $arr)
- $resultData[] = $arr;
- $result = $this->getResult();
- $result->setIndexedTagName($resultData, $this->bl_code);
- $result->addValue('query', $this->getModuleName(), $resultData);
+ if ( is_null( $resultPageSet ) ) {
+ // Try to add the result data in one go and pray that it fits
+ $fit = $this->getResult()->addValue( 'query', $this->getModuleName(), array_values( $this->resultArr ) );
+ if ( !$fit )
+ {
+ // It didn't fit. Add elements one by one until the
+ // result is full.
+ foreach ( $this->resultArr as $pageID => $arr )
+ {
+ // Add the basic entry without redirlinks first
+ $fit = $this->getResult()->addValue(
+ array( 'query', $this->getModuleName() ),
+ null, array_diff_key( $arr, array( 'redirlinks' => '' ) ) );
+ if ( !$fit )
+ {
+ $this->continueStr = $this->getContinueStr( $pageID );
+ break;
+ }
+
+ $hasRedirs = false;
+ foreach ( (array)@$arr['redirlinks'] as $key => $redir )
+ {
+ $fit = $this->getResult()->addValue(
+ array( 'query', $this->getModuleName(), $pageID, 'redirlinks' ),
+ $key, $redir );
+ if ( !$fit )
+ {
+ $this->continueStr = $this->getContinueRedirStr( $pageID, $redir['pageid'] );
+ break;
+ }
+ $hasRedirs = true;
+ }
+ if ( $hasRedirs )
+ $this->getResult()->setIndexedTagName_internal(
+ array( 'query', $this->getModuleName(), $pageID, 'redirlinks' ),
+ $this->bl_code );
+ if ( !$fit )
+ break;
+ }
+ }
+
+ $this->getResult()->setIndexedTagName_internal(
+ array( 'query', $this->getModuleName() ),
+ $this->bl_code );