X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQuery.php;h=304d0f0a662719de70aaf0a30abfc91fb84d84b2;hb=59ebff658ce912c1b0e7ef8d8f9bfec5a4e17b39;hp=ac894193a31c380b5fc3da077a8d7c509cca793f;hpb=c9a815608f8878af5c3931b03866e8aced7ba644;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index ac894193a3..5378e9259f 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -257,11 +257,11 @@ class ApiQuery extends ApiBase { $this->instantiateModules( $allModules, 'meta' ); // Filter modules based on continue parameter - list( $generatorDone, $modules ) = $this->getResult()->beginContinuation( - $this->mParams['continue'], $allModules, $propModules - ); + $continuationManager = new ApiContinuationManager( $this, $allModules, $propModules ); + $this->setContinuationManager( $continuationManager ); + $modules = $continuationManager->getRunModules(); - if ( !$generatorDone ) { + if ( !$continuationManager->isGeneratorDone() ) { // Query modules may optimize data requests through the $this->getPageSet() // object by adding extra fields from the page table. foreach ( $modules as $module ) { @@ -291,19 +291,25 @@ class ApiQuery extends ApiBase { $this->getMain()->setCacheMode( $cacheMode ); // Write the continuation data into the result - $this->getResult()->endContinuation( - $this->mParams['continue'] === null ? 'raw' : 'standard' - ); + $this->setContinuationManager( null ); + if ( $this->mParams['rawcontinue'] ) { + $data = $continuationManager->getRawContinuation(); + if ( $data ) { + $this->getResult()->addValue( null, 'query-continue', $data, + ApiResult::ADD_ON_TOP | ApiResult::NO_SIZE_CHECK ); + } + } else { + $continuationManager->setContinuationIntoResult( $this->getResult() ); + } + /// @todo: Remove this after a suitable period of time. When REL1_26 is cut, if not before. if ( $this->mParams['continue'] === null && !$this->mParams['rawcontinue'] && - array_key_exists( 'query-continue', $this->getResult()->getData() ) + $this->getResult()->getResultData( 'continue' ) !== null ) { - $this->logFeatureUsage( 'action=query&!rawcontinue&!continue' ); $this->setWarning( - 'Formatting of continuation data will be changing soon. ' . - 'To continue using the current formatting, use the \'rawcontinue\' parameter. ' . - 'To begin using the new format, pass an empty string for \'continue\' ' . - 'in the initial query.' + 'Formatting of continuation data has changed. ' . + 'To receive raw query-continue data, use the \'rawcontinue\' parameter. ' . + 'To silence this warning, pass an empty string for \'continue\' in the initial query.' ); } } @@ -396,18 +402,18 @@ class ApiQuery extends ApiBase { foreach ( $pageSet->getMissingTitles() as $fakeId => $title ) { $vals = array(); ApiQueryBase::addTitleInfo( $vals, $title ); - $vals['missing'] = ''; + $vals['missing'] = true; $pages[$fakeId] = $vals; } // Report any invalid titles - foreach ( $pageSet->getInvalidTitles() as $fakeId => $title ) { - $pages[$fakeId] = array( 'title' => $title, 'invalid' => '' ); + foreach ( $pageSet->getInvalidTitlesAndReasons() as $fakeId => $data ) { + $pages[$fakeId] = $data + array( 'invalid' => true ); } // Report any missing page ids foreach ( $pageSet->getMissingPageIDs() as $pageid ) { $pages[$pageid] = array( 'pageid' => $pageid, - 'missing' => '' + 'missing' => true ); } // Report special pages @@ -415,15 +421,15 @@ class ApiQuery extends ApiBase { foreach ( $pageSet->getSpecialTitles() as $fakeId => $title ) { $vals = array(); ApiQueryBase::addTitleInfo( $vals, $title ); - $vals['special'] = ''; + $vals['special'] = true; if ( $title->isSpecialPage() && !SpecialPageFactory::exists( $title->getDBkey() ) ) { - $vals['missing'] = ''; + $vals['missing'] = true; } elseif ( $title->getNamespace() == NS_MEDIA && !wfFindFile( $title ) ) { - $vals['missing'] = ''; + $vals['missing'] = true; } $pages[$fakeId] = $vals; } @@ -438,16 +444,17 @@ class ApiQuery extends ApiBase { if ( count( $pages ) ) { $pageSet->populateGeneratorData( $pages ); + ApiResult::setArrayType( $pages, 'BCarray' ); if ( $this->mParams['indexpageids'] ) { - $pageIDs = array_keys( $pages ); + $pageIDs = array_keys( ApiResult::stripMetadataNonRecursive( $pages ) ); // json treats all map keys as strings - converting to match $pageIDs = array_map( 'strval', $pageIDs ); - $result->setIndexedTagName( $pageIDs, 'id' ); + ApiResult::setIndexedTagName( $pageIDs, 'id' ); $fit = $fit && $result->addValue( 'query', 'pageids', $pageIDs ); } - $result->setIndexedTagName( $pages, 'page' ); + ApiResult::setIndexedTagName( $pages, 'page' ); $fit = $fit && $result->addValue( 'query', 'pages', $pages ); } @@ -476,8 +483,8 @@ class ApiQuery extends ApiBase { */ public function setGeneratorContinue( $module, $paramName, $paramValue ) { wfDeprecated( __METHOD__, '1.24' ); - $this->getResult()->setGeneratorContinueParam( $module, $paramName, $paramValue ); - return $this->getParameter( 'continue' ) !== null; + $this->getContinuationManager()->addGeneratorContinueParam( $module, $paramName, $paramValue ); + return !$this->getParameter( 'rawcontinue' ); } /** @@ -518,9 +525,8 @@ class ApiQuery extends ApiBase { $result->addValue( null, 'text', $exportxml, ApiResult::NO_SIZE_CHECK ); $result->addValue( null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK ); } else { - $r = array(); - ApiResult::setContent( $r, $exportxml ); - $result->addValue( 'query', 'export', $r, ApiResult::NO_SIZE_CHECK ); + $result->addValue( 'query', 'export', $exportxml, ApiResult::NO_SIZE_CHECK ); + $result->addValue( 'query', ApiResult::META_BC_SUBELEMENTS, array( 'export' ) ); } } @@ -542,7 +548,9 @@ class ApiQuery extends ApiBase { 'export' => false, 'exportnowrap' => false, 'iwurl' => false, - 'continue' => null, + 'continue' => array( + ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', + ), 'rawcontinue' => false, ); if ( $flags ) {