private function reparseToFetchSemanticData($title)
 {
     $contentParser = $this->applicationFactory->newContentParser($title);
     $parserOutput = $contentParser->parse()->getOutput();
     if ($parserOutput === null) {
         return null;
     }
     if (method_exists($parserOutput, 'getExtensionData')) {
         return $parserOutput->getExtensionData('smwdata');
     }
     return $parserOutput->mSMWData;
 }
예제 #2
0
 /**
  * #347 showed that an external process (e.g. RefreshLinksJob) can inject a
  * ParserOutput without/cleared SemanticData which forces the Store updater
  * to create an empty container that will clear all existing data.
  * 
  * To ensure that for a Title and its current revision an empty ParserOutput
  * object is really meant to be "empty" (e.g. delete action initiated by a
  * human) the content is re-parsed in order to fetch the newest available data
  *
  * @note Parsing is expensive but it is more expensive to loose data or to
  * expect that an external process adheres the object contract
  */
 private function refetchSemanticData()
 {
     wfDebug(__METHOD__ . ' Empty SemanticData / re-parsing: ' . $this->linksUpdate->getTitle()->getPrefixedDBkey() . "\n");
     $contentParser = $this->applicationFactory->newContentParser($this->linksUpdate->getTitle());
     $parserOutput = $contentParser->parse()->getOutput();
     if ($parserOutput === null) {
         return null;
     }
     if (method_exists($parserOutput, 'getExtensionData')) {
         return $parserOutput->getExtensionData('smwdata');
     }
     return $parserOutput->mSMWData;
 }
예제 #3
0
 private function needToParsePageContentBeforeUpdate()
 {
     $contentParser = $this->applicationFactory->newContentParser($this->getTitle());
     $contentParser->forceToUseParser();
     $contentParser->parse();
     if (!$contentParser->getOutput() instanceof ParserOutput) {
         $this->setLastError($contentParser->getErrors());
         return false;
     }
     $parserData = $this->applicationFactory->newParserData($this->getTitle(), $contentParser->getOutput());
     return $this->updateStore($parserData);
 }
예제 #4
0
 /**
  * SMW_UJ_PM_NP = new Parser to avoid "Parser state cleared" exception
  */
 private function needToParsePageContentBeforeUpdate()
 {
     $contentParser = $this->applicationFactory->newContentParser($this->getTitle());
     if ($this->getParameter('pm') === ($this->getParameter('pm') | SMW_UJ_PM_NP)) {
         $contentParser->setParser(new \Parser($GLOBALS['wgParserConf']));
     }
     $contentParser->parse();
     if (!$contentParser->getOutput() instanceof ParserOutput) {
         $this->setLastError($contentParser->getErrors());
         return false;
     }
     $parserData = $this->applicationFactory->newParserData($this->getTitle(), $contentParser->getOutput());
     return $this->updateStore($parserData);
 }