Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -284,19 +284,25 @@ |
285 | 285 | $result = new SMWQueryResult($prs, $query, ($count > $query->getLimit()) ); |
286 | 286 | foreach ($qr as $qt) { |
287 | 287 | $row = array(); |
| 288 | + $cats = false; |
288 | 289 | foreach ($prs as $pr) { |
289 | 290 | switch ($pr->getMode()) { |
290 | 291 | case SMWPrintRequest::PRINT_THIS: |
291 | 292 | $row[] = new SMWResultArray(array($qt), $pr); |
292 | 293 | break; |
293 | 294 | case SMWPrintRequest::PRINT_CATS: |
294 | | - $row[] = new SMWResultArray($this->m_store->getPropertyValues($qt,SMWPropertyValue::makeProperty('_INST')), $pr); |
| 295 | + if ($cats === false) { |
| 296 | + $cats = $this->m_store->getPropertyValues($qt,SMWPropertyValue::makeProperty('_INST')); |
| 297 | + } |
| 298 | + $row[] = new SMWResultArray($cats, $pr); |
295 | 299 | break; |
296 | 300 | case SMWPrintRequest::PRINT_PROP: |
297 | 301 | $row[] = new SMWResultArray($this->m_store->getPropertyValues($qt,$pr->getData(), NULL, $pr->getOutputFormat()), $pr); |
298 | 302 | break; |
299 | 303 | case SMWPrintRequest::PRINT_CCAT: |
300 | | - $cats = $this->m_store->getPropertyValues($qt,SMWPropertyValue::makeProperty('_INST')); |
| 304 | + if ($cats === false) { |
| 305 | + $cats = $this->m_store->getPropertyValues($qt,SMWPropertyValue::makeProperty('_INST')); |
| 306 | + } |
301 | 307 | $found = '0'; |
302 | 308 | foreach ($cats as $cat) { |
303 | 309 | if ($cat->getDBkey() == $pr->getData()->getDBkey()) { |
— | — | @@ -391,12 +397,12 @@ |
392 | 398 | array('s_id'=>$cid), 'SMWSQLStore2Queries::compileQueries'); |
393 | 399 | if ( $row === false ) { // no description found, concept does not exist |
394 | 400 | // keep the above query object, it yields an empty result |
395 | | - ///TODO: announce an error here? (maybe not, since the query processor can check for |
| 401 | + ///TODO: announce an error here? (maybe not, since the query processor can check for |
396 | 402 | ///non-existing concept pages which is probably the main reason for finding nothing here |
397 | 403 | } else { |
398 | 404 | global $smwgQConceptCaching, $smwgQMaxSize, $smwgQMaxDepth, $smwgQFeatures, $smwgQConceptCacheLifetime; |
399 | 405 | $may_be_computed = ($smwgQConceptCaching == CONCEPT_CACHE_NONE) || |
400 | | - ( ($smwgQConceptCaching == CONCEPT_CACHE_HARD) && ( (~(~($row->concept_features+0) | $smwgQFeatures)) == 0) && |
| 406 | + ( ($smwgQConceptCaching == CONCEPT_CACHE_HARD) && ( (~(~($row->concept_features+0) | $smwgQFeatures)) == 0) && |
401 | 407 | ($smwgQMaxSize >= $row->concept_size) && ($smwgQMaxDepth >= $row->concept_depth)); |
402 | 408 | if ($row->cache_date && |
403 | 409 | ($row->cache_date > (strtotime("now") - $smwgQConceptCacheLifetime*60) || |
— | — | @@ -654,7 +660,7 @@ |
655 | 661 | $sql = "INSERT IGNORE INTO " . $this->m_dbs->tableName($query->alias) . " SELECT $subquery->joinfield FROM " . |
656 | 662 | $this->m_dbs->tableName($subquery->jointable) . " AS $subquery->alias $subquery->from" . ($subquery->where?" WHERE $subquery->where":''); |
657 | 663 | } elseif ($subquery->joinfield !== '') { |
658 | | - /// NOTE: this works only for single "unconditional" values without further |
| 664 | + /// NOTE: this works only for single "unconditional" values without further |
659 | 665 | /// WHERE or FROM. The execution must take care of not creating any others. |
660 | 666 | $values = ''; |
661 | 667 | foreach ($subquery->joinfield as $value) { |
— | — | @@ -680,7 +686,7 @@ |
681 | 687 | case SMW_SQL2_VALUE: break; // nothing to do |
682 | 688 | } |
683 | 689 | } |
684 | | - |
| 690 | + |
685 | 691 | /** |
686 | 692 | * Find subproperties or subcategories. This may require iterative computation, |
687 | 693 | * and temporary tables are used in many cases. |
— | — | @@ -732,7 +738,7 @@ |
733 | 739 | |
734 | 740 | /// NOTE: we use two helper tables. One holds the results of each new iteration, one holds the |
735 | 741 | /// results of the previous iteration. One could of course do with only the above result table, |
736 | | - /// but then every iteration would use all elements of this table, while only the new ones |
| 742 | + /// but then every iteration would use all elements of this table, while only the new ones |
737 | 743 | /// obtained in the previous step are relevant. So this is a performance measure. |
738 | 744 | $tmpnew = 'smw_new'; |
739 | 745 | $tmpres = 'smw_res'; |
— | — | @@ -767,8 +773,8 @@ |
768 | 774 | } |
769 | 775 | |
770 | 776 | /** |
771 | | - * This function modifies the given query object at $qid to account for all ordering conditions |
772 | | - * in the SMWQuery $query. It is always required that $qid is the id of a query that joins with |
| 777 | + * This function modifies the given query object at $qid to account for all ordering conditions |
| 778 | + * in the SMWQuery $query. It is always required that $qid is the id of a query that joins with |
773 | 779 | * smw_ids so that the field alias.smw_title is $available for default sorting. |
774 | 780 | */ |
775 | 781 | protected function applyOrderConditions($query, $qid) { |