Esempio n. 1
0
 /**
  * Run job
  * @return boolean success
  */
 function run()
 {
     wfProfileIn('SMWUpdateJob::run (SMW)');
     global $wgParser;
     LinkCache::singleton()->clear();
     if (is_null($this->title)) {
         $this->error = "SMWUpdateJob: Invalid title";
         wfProfileOut('SMWUpdateJob::run (SMW)');
         return false;
     } elseif (!$this->title->exists()) {
         smwfGetStore()->deleteSubject($this->title);
         // be sure to clear the data
         wfProfileOut('SMWUpdateJob::run (SMW)');
         return true;
     }
     $revision = Revision::newFromTitle($this->title);
     if (!$revision) {
         $this->error = 'SMWUpdateJob: Page exists but no revision was found for "' . $this->title->getPrefixedDBkey() . '"';
         wfProfileOut('SMWUpdateJob::run (SMW)');
         return false;
     }
     wfProfileIn(__METHOD__ . '-parse');
     $options = new ParserOptions();
     $output = $wgParser->parse($revision->getText(), $this->title, $options, true, true, $revision->getID());
     wfProfileOut(__METHOD__ . '-parse');
     wfProfileIn(__METHOD__ . '-update');
     SMWParseData::storeData($output, $this->title, false);
     wfProfileOut(__METHOD__ . '-update');
     wfProfileOut('SMWUpdateJob::run (SMW)');
     return true;
 }
 public static function onParserAfterTidy(&$parser, &$text)
 {
     $title = $parser->getTitle();
     // make sure this isn't some title we didn't wanted to purge in the first place:
     if (self::hasUpdateTitle($title)) {
         /* 
          * Note: don't use SMWUpdateJob here because it would parse the whole article again and 
          * could cause some problems with very dynamic extensions like Extension:Variables.
          */
         $output = $parser->getOutput();
         // only update if the page contains semantic data:
         if (isset($output->mSMWData)) {
             SMWParseData::storeData($output, $title, true);
         }
         self::removeUpdateTitle($title);
     }
     return true;
 }