当前位置: 首页>>代码示例>>PHP>>正文


PHP ApiPageSet::getCacheMode方法代码示例

本文整理汇总了PHP中ApiPageSet::getCacheMode方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiPageSet::getCacheMode方法的具体用法?PHP ApiPageSet::getCacheMode怎么用?PHP ApiPageSet::getCacheMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiPageSet的用法示例。


在下文中一共展示了ApiPageSet::getCacheMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Query execution happens in the following steps:
  * #1 Create a PageSet object with any pages requested by the user
  * #2 If using a generator, execute it to get a new ApiPageSet object
  * #3 Instantiate all requested modules.
  *    This way the PageSet object will know what shared data is required,
  *    and minimize DB calls.
  * #4 Output all normalization and redirect resolution information
  * #5 Execute all requested modules
  */
 public function execute()
 {
     $this->mParams = $this->extractRequestParams();
     // Instantiate requested modules
     $allModules = array();
     $this->instantiateModules($allModules, 'prop');
     $propModules = array_keys($allModules);
     $this->instantiateModules($allModules, 'list');
     $this->instantiateModules($allModules, 'meta');
     // Filter modules based on continue parameter
     $continuationManager = new ApiContinuationManager($this, $allModules, $propModules);
     $this->setContinuationManager($continuationManager);
     $modules = $continuationManager->getRunModules();
     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) {
             $module->requestExtraData($this->mPageSet);
         }
         // Populate page/revision information
         $this->mPageSet->execute();
         // Record page information (title, namespace, if exists, etc)
         $this->outputGeneralPageInfo();
     } else {
         $this->mPageSet->executeDryRun();
     }
     $cacheMode = $this->mPageSet->getCacheMode();
     // Execute all unfinished modules
     /** @var $module ApiQueryBase */
     foreach ($modules as $module) {
         $params = $module->extractRequestParams();
         $cacheMode = $this->mergeCacheMode($cacheMode, $module->getCacheMode($params));
         $module->execute();
         Hooks::run('APIQueryAfterExecute', array(&$module));
     }
     // Set the cache mode
     $this->getMain()->setCacheMode($cacheMode);
     // Write the continuation data into the result
     $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'] && $this->getResult()->getResultData('continue') !== null) {
         $this->setWarning('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.');
     }
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:62,代码来源:ApiQuery.php

示例2: execute

 /**
  * Query execution happens in the following steps:
  * #1 Create a PageSet object with any pages requested by the user
  * #2 If using a generator, execute it to get a new ApiPageSet object
  * #3 Instantiate all requested modules.
  *    This way the PageSet object will know what shared data is required,
  *    and minimize DB calls.
  * #4 Output all normalization and redirect resolution information
  * #5 Execute all requested modules
  */
 public function execute()
 {
     $this->mParams = $this->extractRequestParams();
     // Instantiate requested modules
     $allModules = [];
     $this->instantiateModules($allModules, 'prop');
     $propModules = array_keys($allModules);
     $this->instantiateModules($allModules, 'list');
     $this->instantiateModules($allModules, 'meta');
     // Filter modules based on continue parameter
     $continuationManager = new ApiContinuationManager($this, $allModules, $propModules);
     $this->setContinuationManager($continuationManager);
     $modules = $continuationManager->getRunModules();
     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) {
             $module->requestExtraData($this->mPageSet);
         }
         // Populate page/revision information
         $this->mPageSet->execute();
         // Record page information (title, namespace, if exists, etc)
         $this->outputGeneralPageInfo();
     } else {
         $this->mPageSet->executeDryRun();
     }
     $cacheMode = $this->mPageSet->getCacheMode();
     // Execute all unfinished modules
     /** @var $module ApiQueryBase */
     foreach ($modules as $module) {
         $params = $module->extractRequestParams();
         $cacheMode = $this->mergeCacheMode($cacheMode, $module->getCacheMode($params));
         $module->execute();
         Hooks::run('APIQueryAfterExecute', [&$module]);
     }
     // Set the cache mode
     $this->getMain()->setCacheMode($cacheMode);
     // Write the continuation data into the result
     $this->setContinuationManager(null);
     if ($this->mParams['rawcontinue']) {
         $data = $continuationManager->getRawNonContinuation();
         if ($data) {
             $this->getResult()->addValue(null, 'query-noncontinue', $data, ApiResult::ADD_ON_TOP | ApiResult::NO_SIZE_CHECK);
         }
         $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());
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:62,代码来源:ApiQuery.php

示例3: execute

 /**
  * Query execution happens in the following steps:
  * #1 Create a PageSet object with any pages requested by the user
  * #2 If using a generator, execute it to get a new ApiPageSet object
  * #3 Instantiate all requested modules.
  *    This way the PageSet object will know what shared data is required,
  *    and minimize DB calls.
  * #4 Output all normalization and redirect resolution information
  * #5 Execute all requested modules
  */
 public function execute()
 {
     $this->mParams = $this->extractRequestParams();
     // Instantiate requested modules
     $allModules = array();
     $this->instantiateModules($allModules, 'prop');
     $propModules = array_keys($allModules);
     $this->instantiateModules($allModules, 'list');
     $this->instantiateModules($allModules, 'meta');
     // Filter modules based on continue parameter
     list($generatorDone, $modules) = $this->getResult()->beginContinuation($this->mParams['continue'], $allModules, $propModules);
     if (!$generatorDone) {
         // Query modules may optimize data requests through the $this->getPageSet()
         // object by adding extra fields from the page table.
         foreach ($modules as $module) {
             $module->requestExtraData($this->mPageSet);
         }
         // Populate page/revision information
         $this->mPageSet->execute();
         // Record page information (title, namespace, if exists, etc)
         $this->outputGeneralPageInfo();
     } else {
         $this->mPageSet->executeDryRun();
     }
     $cacheMode = $this->mPageSet->getCacheMode();
     // Execute all unfinished modules
     /** @var $module ApiQueryBase */
     foreach ($modules as $module) {
         $params = $module->extractRequestParams();
         $cacheMode = $this->mergeCacheMode($cacheMode, $module->getCacheMode($params));
         $module->profileIn();
         $module->execute();
         wfRunHooks('APIQueryAfterExecute', array(&$module));
         $module->profileOut();
     }
     // Set the cache mode
     $this->getMain()->setCacheMode($cacheMode);
     // Write the continuation data into the result
     $this->getResult()->endContinuation($this->mParams['continue'] === null ? 'raw' : 'standard');
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:50,代码来源:ApiQuery.php

示例4: execute

 /**
  * Query execution happens in the following steps:
  * #1 Create a PageSet object with any pages requested by the user
  * #2 If using a generator, execute it to get a new ApiPageSet object
  * #3 Instantiate all requested modules.
  *    This way the PageSet object will know what shared data is required,
  *    and minimize DB calls.
  * #4 Output all normalization and redirect resolution information
  * #5 Execute all requested modules
  */
 public function execute()
 {
     $this->mParams = $this->extractRequestParams();
     // $pagesetParams is a array of parameter names used by the pageset generator
     //   or null if pageset has already finished and is no longer needed
     // $completeModules is a set of complete modules with the name as key
     $this->initContinue($pagesetParams, $completeModules);
     // Instantiate requested modules
     $allModules = array();
     $this->instantiateModules($allModules, 'prop');
     $propModules = $allModules;
     // Keep a copy
     $this->instantiateModules($allModules, 'list');
     $this->instantiateModules($allModules, 'meta');
     // Filter modules based on continue parameter
     $modules = $this->initModules($allModules, $completeModules, $pagesetParams !== null);
     // Execute pageset if in legacy mode or if pageset is not done
     if ($completeModules === null || $pagesetParams !== null) {
         // Populate page/revision information
         $this->mPageSet->execute();
         // Record page information (title, namespace, if exists, etc)
         $this->outputGeneralPageInfo();
     } else {
         $this->mPageSet->executeDryRun();
     }
     $cacheMode = $this->mPageSet->getCacheMode();
     // Execute all unfinished modules
     /** @var $module ApiQueryBase */
     foreach ($modules as $module) {
         $params = $module->extractRequestParams();
         $cacheMode = $this->mergeCacheMode($cacheMode, $module->getCacheMode($params));
         $module->profileIn();
         $module->execute();
         wfRunHooks('APIQueryAfterExecute', array(&$module));
         $module->profileOut();
     }
     // Set the cache mode
     $this->getMain()->setCacheMode($cacheMode);
     if ($completeModules === null) {
         return;
         // Legacy continue, we are done
     }
     // Reformat query-continue result section
     $result = $this->getResult();
     $qc = $result->getData();
     if (isset($qc['query-continue'])) {
         $qc = $qc['query-continue'];
         $result->unsetValue(null, 'query-continue');
     } elseif ($this->mGeneratorContinue !== null) {
         $qc = array();
     } else {
         // no more "continue"s, we are done!
         return;
     }
     // we are done with all the modules that do not have result in query-continue
     $completeModules = array_merge($completeModules, array_diff_key($modules, $qc));
     if ($pagesetParams !== null) {
         // The pageset is still in use, check if all props have finished
         $incompleteProps = array_intersect_key($propModules, $qc);
         if (count($incompleteProps) > 0) {
             // Properties are not done, continue with the same pageset state - copy current parameters
             $main = $this->getMain();
             $contValues = array();
             foreach ($pagesetParams as $param) {
                 // The param name is already prefix-encoded
                 $contValues[$param] = $main->getVal($param);
             }
         } elseif ($this->mGeneratorContinue !== null) {
             // Move to the next set of pages produced by pageset, properties need to be restarted
             $contValues = $this->mGeneratorContinue;
             $pagesetParams = array_keys($contValues);
             $completeModules = array_diff_key($completeModules, $propModules);
         } else {
             // Done with the pageset, finish up with the the lists and meta modules
             $pagesetParams = null;
         }
     }
     $continue = '||' . implode('|', array_keys($completeModules));
     if ($pagesetParams !== null) {
         // list of all pageset parameters to use in the next request
         $continue = implode('|', $pagesetParams) . $continue;
     } else {
         // we are done with the pageset
         $contValues = array();
         $continue = '-' . $continue;
     }
     $contValues['continue'] = $continue;
     foreach ($qc as $qcModule) {
         foreach ($qcModule as $qcKey => $qcValue) {
             $contValues[$qcKey] = $qcValue;
//.........这里部分代码省略.........
开发者ID:Tarendai,项目名称:spring-website,代码行数:101,代码来源:ApiQuery.php


注:本文中的ApiPageSet::getCacheMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。