Example #1
0
 /**
  * @return bool
  */
 public function doWork()
 {
     global $wgUseFileCache;
     // @todo several of the methods called on $this->page are not declared in Page, but present
     //        in WikiPage and delegated by Article.
     $isCurrent = $this->revid === $this->page->getLatest();
     if ($this->content !== null) {
         $content = $this->content;
     } elseif ($isCurrent) {
         // XXX: why use RAW audience here, and PUBLIC (default) below?
         $content = $this->page->getContent(Revision::RAW);
     } else {
         $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
         if ($rev === null) {
             $content = null;
         } else {
             // XXX: why use PUBLIC audience here (default), and RAW above?
             $content = $rev->getContent();
         }
     }
     if ($content === null) {
         return false;
     }
     // Reduce effects of race conditions for slow parses (bug 46014)
     $cacheTime = wfTimestampNow();
     $time = -microtime(true);
     $this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions);
     $time += microtime(true);
     // Timing hack
     if ($time > 3) {
         wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->page->getTitle()->getPrefixedDBkey()));
     }
     if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) {
         ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->parserOutput->isCacheable() || $this->parserOutput->containsOldMagic()) {
         $wgUseFileCache = false;
     }
     if ($isCurrent) {
         $this->page->doCascadeProtectionUpdates($this->parserOutput);
     }
     return true;
 }
Example #2
0
 /**
  * @return bool
  */
 function doWork()
 {
     global $wgParser, $wgUseFileCache;
     $isCurrent = $this->revid === $this->page->getLatest();
     if ($this->text !== null) {
         $text = $this->text;
     } elseif ($isCurrent) {
         $text = $this->page->getRawText();
     } else {
         $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
         if ($rev === null) {
             return false;
         }
         $text = $rev->getText();
     }
     $time = -microtime(true);
     $this->parserOutput = $wgParser->parse($text, $this->page->getTitle(), $this->parserOptions, true, true, $this->revid);
     $time += microtime(true);
     # Timing hack
     if ($time > 3) {
         wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->page->getTitle()->getPrefixedDBkey()));
     }
     if ($this->cacheable && $this->parserOutput->isCacheable()) {
         ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->parserOutput->isCacheable() || $this->parserOutput->containsOldMagic()) {
         $wgUseFileCache = false;
     }
     if ($isCurrent) {
         $this->page->doCascadeProtectionUpdates($this->parserOutput);
     }
     return true;
 }