Пример #1
0
 /**
  * @param Page $page
  * @param ParserOptions $parserOptions ParserOptions to use for the parse
  * @param int $revid ID of the revision being parsed.
  * @param bool $useParserCache Whether to use the parser cache.
  *   operation.
  * @param Content|string $content Content to parse or null to load it; may
  *   also be given as a wikitext string, for BC.
  */
 public function __construct(Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null)
 {
     if (is_string($content)) {
         // BC: old style call
         $modelId = $page->getRevision()->getContentModel();
         $format = $page->getRevision()->getContentFormat();
         $content = ContentHandler::makeContent($content, $page->getTitle(), $modelId, $format);
     }
     $this->page = $page;
     $this->revid = $revid;
     $this->cacheable = $useParserCache;
     $this->parserOptions = $parserOptions;
     $this->content = $content;
     $this->cacheKey = ParserCache::singleton()->getKey($page, $parserOptions);
     parent::__construct('ArticleView', $this->cacheKey . ':revid:' . $revid);
 }
 /**
  * Build a PoolCounterWork class from a type, key, and callback map.
  *
  * The callback map must at least have a callback for the 'doWork' method.
  * Additionally, callbacks can be provided for the 'doCachedWork', 'fallback',
  * and 'error' methods. Methods without callbacks will be no-ops that return false.
  * If a 'doCachedWork' callback is provided, then execute() may wait for any prior
  * process in the pool to finish and reuse its cached result.
  *
  * @param string $type
  * @param string $key
  * @param array $callbacks Map of callbacks
  * @throws MWException
  */
 public function __construct($type, $key, array $callbacks)
 {
     parent::__construct($type, $key);
     foreach (array('doWork', 'doCachedWork', 'fallback', 'error') as $name) {
         if (isset($callbacks[$name])) {
             if (!is_callable($callbacks[$name])) {
                 throw new MWException("Invalid callback provided for '{$name}' function.");
             }
             $this->{$name} = $callbacks[$name];
         }
     }
     if (!isset($this->doWork)) {
         throw new MWException("No callback provided for 'doWork' function.");
     }
     $this->cacheable = isset($this->doCachedWork);
 }
Пример #3
0
 function __construct($article, $key, $useParserCache, $parserOptions)
 {
     parent::__construct('ArticleView', $key);
     $this->mArticle = $article;
     $this->cacheable = $useParserCache;
     $this->parserOptions = $parserOptions;
 }
Пример #4
0
 /**
  * Constructor
  *
  * @param $page Page
  * @param $revid Integer: ID of the revision being parsed
  * @param $useParserCache Boolean: whether to use the parser cache
  * @param $parserOptions parserOptions to use for the parse operation
  * @param $text String: text to parse or null to load it
  */
 function __construct(Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $text = null)
 {
     $this->page = $page;
     $this->revid = $revid;
     $this->cacheable = $useParserCache;
     $this->parserOptions = $parserOptions;
     $this->text = $text;
     $this->cacheKey = ParserCache::singleton()->getKey($page, $parserOptions);
     parent::__construct('ArticleView', $this->cacheKey . ':revid:' . $revid);
 }