private function doFetchResultsForRawParameters(array $rawParams)
 {
     // FIXME QueryDuration should be a property of the QueryProcessor or
     // QueryEngine but since we don't want to open the pandora's box and
     // increase issues within the current QueryProcessor implementation
     // we will track the time outside of the actual execution framework
     $queryDuration = 0;
     $start = microtime(true);
     list($this->query, $this->params) = SMWQueryProcessor::getQueryAndParamsFromFunctionParams($rawParams, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY, $this->showMode);
     $this->query->setSubject(DIWIkiPage::newFromTitle($this->parserData->getTitle()));
     $queryHash = $this->query->getHash();
     $this->circularReferenceGuard->mark($queryHash);
     // If we caught in a circular loop (due to a template referencing to itself)
     // then we stop here before the next query execution to avoid an infinite
     // self-reference
     if ($this->circularReferenceGuard->isCircularByRecursionFor($queryHash)) {
         return '';
     }
     $result = SMWQueryProcessor::getResultFromQuery($this->query, $this->params, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY);
     $format = $this->params['format']->getValue();
     // FIXME Parser should be injected into the ResultPrinter
     // Enables specific formats to import its annotation data from
     // a recursive parse process in the result format
     // e.g. using ask query to search/set an invert property value
     if (isset($this->params['import-annotation']) && $this->params['import-annotation']->getValue()) {
         $this->parserData->importFromParserOutput($GLOBALS['wgParser']->getOutput());
     }
     if ($this->applicationFactory->getSettings()->get('smwgQueryDurationEnabled')) {
         $queryDuration = microtime(true) - $start;
     }
     $this->circularReferenceGuard->unmark($queryHash);
     $this->createQueryProfile($this->query, $format, $queryDuration);
     return $result;
 }
예제 #2
0
 private function doFetchResultsForRawParameters(array $rawParams)
 {
     // FIXME QueryDuration should be a property of the QueryProcessor or
     // QueryEngine but since we don't want to open the pandora's box and
     // increase issues within the current QueryProcessor implementation
     // we will track the time outside of the actual execution framework
     $queryDuration = 0;
     $start = microtime(true);
     list($this->query, $this->params) = SMWQueryProcessor::getQueryAndParamsFromFunctionParams($rawParams, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY, $this->showMode);
     $queryHash = $this->query->getHash();
     $this->circularReferenceGuard->mark($queryHash);
     // If we caught in a circular loop (due to a template referencing to itself)
     // then we stop here before the next query execution to avoid an infinite
     // self-reference
     if ($this->circularReferenceGuard->isCircularByRecursionFor($queryHash)) {
         return '';
     }
     $result = SMWQueryProcessor::getResultFromQuery($this->query, $this->params, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY);
     // FIXME Should be injected
     // A printer run its own isolated wgParser process therefore if the printer
     // or a template inclusion is used by a printer, possible extra annotations
     // need to be imported for further usage
     $this->parserData->importFromParserOutput($GLOBALS['wgParser']->getOutput());
     if ($this->applicationFactory->getSettings()->get('smwgQueryDurationEnabled')) {
         $queryDuration = microtime(true) - $start;
     }
     $this->circularReferenceGuard->unmark($queryHash);
     $this->createQueryProfile($this->query, $this->params['format']->getValue(), $queryDuration);
     return $result;
 }
 private function doFetchResultsForRawParameters(array $rawParams)
 {
     $contextPage = $this->parserData->getSubject();
     list($query, $this->params) = SMWQueryProcessor::getQueryAndParamsFromFunctionParams($rawParams, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY, $this->showMode, $contextPage);
     $query->setContextPage($contextPage);
     $queryHash = $query->getHash();
     $this->circularReferenceGuard->mark($queryHash);
     // If we caught in a circular loop (due to a template referencing to itself)
     // then we stop here before the next query execution to avoid an infinite
     // self-reference
     if ($this->circularReferenceGuard->isCircularByRecursionFor($queryHash)) {
         return '';
     }
     $result = SMWQueryProcessor::getResultFromQuery($query, $this->params, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY);
     $format = $this->params['format']->getValue();
     // FIXME Parser should be injected into the ResultPrinter
     // Enables specific formats to import its annotation data from
     // a recursive parse process in the result format
     // e.g. using ask query to search/set an invert property value
     if (isset($this->params['import-annotation']) && $this->params['import-annotation']->getValue()) {
         $this->parserData->importFromParserOutput($GLOBALS['wgParser']->getOutput());
     }
     $this->circularReferenceGuard->unmark($queryHash);
     // In case of an query error add a marker to the subject for discoverability
     // of a failed query, don't bail-out as we can have results and errors
     // at the same time
     if ($query->getErrors() !== array()) {
         $this->addProcessingError($query->getErrors());
     }
     $this->createQueryProfile($query, $format);
     return $result;
 }
예제 #4
0
 public function testImportFromParserOutput()
 {
     $import = new ParserData(Title::newFromText(__METHOD__), new ParserOutput());
     $import->addDataValue($this->dataValueFactory->newDataValueByText('Foo', 'Bar'));
     $import->pushSemanticDataToParserOutput();
     $instance = new ParserData(Title::newFromText(__METHOD__), new ParserOutput());
     $instance->importFromParserOutput(null);
     $this->assertNotEquals($import->getSemanticData()->getHash(), $instance->getSemanticData()->getHash());
     $instance->importFromParserOutput($import->getOutput());
     $this->assertEquals($import->getSemanticData()->getHash(), $instance->getSemanticData()->getHash());
 }