Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -283,6 +283,7 @@ |
284 | 284 | * The call-by-ref parameter $label is used to append any label strings found. |
285 | 285 | */ |
286 | 286 | protected function getSubqueryDescription(&$setNS, &$label) { |
| 287 | + global $smwgQPrintoutLimit; |
287 | 288 | $conjunction = NULL; // used for the current inner conjunction |
288 | 289 | $disjuncts = array(); // (disjunctive) array of subquery conjunctions |
289 | 290 | $printrequests = array(); // the printrequests found for this query level |
— | — | @@ -369,8 +370,15 @@ |
370 | 371 | } |
371 | 372 | $setNS = $mustSetNS; // NOTE: also false if namespaces were given but no default NS descs are available |
372 | 373 | |
| 374 | + $prcount = 0; |
373 | 375 | foreach ($printrequests as $pr) { // add printrequests |
374 | | - $result->addPrintRequest($pr); |
| 376 | + if ($prcount < $smwgQPrintoutLimit) { |
| 377 | + $result->addPrintRequest($pr); |
| 378 | + $prcount++; |
| 379 | + } else { |
| 380 | + $this->m_errors[] = 'Too many printout requests.'; |
| 381 | + break; |
| 382 | + } |
375 | 383 | } |
376 | 384 | return $result; |
377 | 385 | } |
— | — | @@ -800,7 +808,13 @@ |
801 | 809 | } elseif ($conjunction) { // make new conjunction |
802 | 810 | return new SMWConjunction(array($curdesc,$newdesc)); |
803 | 811 | } else { // make new disjunction |
804 | | - return new SMWDisjunction(array($curdesc,$newdesc)); |
| 812 | + global $smwgQDisjunctionSupport; |
| 813 | + if ($smwgQDisjunctionSupport) { |
| 814 | + return new SMWDisjunction(array($curdesc,$newdesc)); |
| 815 | + } else { |
| 816 | + $this->m_errors[] = 'Disjunctions in queries not supported in this wiki, dropped part of query (' . $newdesc->getQueryString() . ').'; |
| 817 | + return $curdesc; |
| 818 | + } |
805 | 819 | } |
806 | 820 | } |
807 | 821 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -612,15 +612,11 @@ |
613 | 613 | /** |
614 | 614 | * The SQL store's implementation of query answering. |
615 | 615 | * |
616 | | - * TODO: decide who respects which global query settings: the query parser or the query execution? |
617 | | - * Probably the query parser (e.g. it can distinguish subqueries from other nested constructs that |
618 | | - * are not "subqueries" from a user perspective, it also has a good insight in the query structure for |
619 | | - * applying structural limits) |
620 | 616 | * TODO: we now have sorting even for subquery conditions. Does this work? Is it slow/problematic? |
621 | 617 | * NOTE: we do not support category wildcards, as they have no useful semantics in OWL/RDFS/LP/whatever |
622 | 618 | */ |
623 | 619 | function getQueryResult(SMWQuery $query) { |
624 | | - global $smwgIQSortingEnabled; |
| 620 | + global $smwgQSortingSupport; |
625 | 621 | |
626 | 622 | $db =& wfGetDB( DB_SLAVE ); |
627 | 623 | $prs = $query->getDescription()->getPrintrequests(); // ignore print requests at deeper levels |
— | — | @@ -640,7 +636,7 @@ |
641 | 637 | $sql_options = array(); |
642 | 638 | $sql_options['LIMIT'] = $query->getLimit() + 1; |
643 | 639 | $sql_options['OFFSET'] = $query->getOffset(); |
644 | | - if ( $smwgIQSortingEnabled ) { |
| 640 | + if ( $smwgQSortingSupport ) { |
645 | 641 | $order = $query->ascending ? 'ASC' : 'DESC'; |
646 | 642 | if ( ($this->m_sortfield == false) && ($this->m_sortkey == false) ) { |
647 | 643 | $sql_options['ORDER BY'] = "$pagetable.page_title $order "; // default |
— | — | @@ -955,6 +951,7 @@ |
956 | 952 | global $wgDBname, $smwgQSubpropertyDepth; |
957 | 953 | |
958 | 954 | $tablename = 'prop' . SMWSQLStore::$m_tablenum++; |
| 955 | + $this->m_usedtables[] = $tablename; |
959 | 956 | $db->query( 'CREATE TEMPORARY TABLE ' . $tablename . |
960 | 957 | '( title VARCHAR(255) NOT NULL ) |
961 | 958 | TYPE=MEMORY', 'SMW::getPropertyTable' ); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php |
— | — | @@ -28,11 +28,11 @@ |
29 | 29 | * that may influence the processing details. |
30 | 30 | */ |
31 | 31 | public function SMWResultPrinter($format, $inline) { |
32 | | - global $smwgIQDefaultLinking; |
| 32 | + global $smwgQDefaultLinking; |
33 | 33 | $this->mFormat = $format; |
34 | 34 | $this->mInline = $inline; |
35 | | - $this->mLinkFirst = ($smwgIQDefaultLinking != 'none'); |
36 | | - $this->mLinkOthers = ($smwgIQDefaultLinking == 'all'); |
| 35 | + $this->mLinkFirst = ($smwgQDefaultLinking != 'none'); |
| 36 | + $this->mLinkOthers = ($smwgQDefaultLinking == 'all'); |
37 | 37 | $this->mLinker = new Linker(); ///TODO: how can we get the default or user skin here (depending on context)? |
38 | 38 | } |
39 | 39 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php |
— | — | @@ -62,27 +62,24 @@ |
63 | 63 | $smwgQSubpropertyDepth = 10; // Restrict level of sub-property inclusion (steps within property hierarchy) |
64 | 64 | // (Use 0 to disable hierarchy-inferencing in queries) |
65 | 65 | $smwgQEqualitySupport = true; // Should #redirects be evaluated as equality between page names? |
| 66 | +$smwgQSortingSupport = true; // (De)activate sorting of results. |
66 | 67 | $smwgQDefaultNamespaces = array(NS_MAIN, NS_IMAGE); // Which namespaces should be searched by default? |
67 | 68 | // (value NULL switches off default restrictions on searching -- this is faster) |
68 | 69 | $smwgQMaxLimit = 10000; // Max number of results ever retrieved, even when using special query pages. |
| 70 | +$smwgQDisjunctionSupport = true; // Support disjunctions in queries (||)? |
| 71 | + // (Note: things like namespace defaults and property/category hierarchies |
| 72 | + // can also cause disjunctions!) |
69 | 73 | |
70 | | - |
71 | 74 | ### Settings about printout of (especially inline) queries: |
72 | 75 | $smwgQDefaultLimit = 50; // Default number of rows returned in a query. Can be increased with <ask limit="num">... |
73 | 76 | $smwgQMaxInlineLimit = 500; // Max number of rows ever printed in a single inline query on a single page. |
| 77 | +$smwgQPrintoutLimit = 10; // Max number of supported printouts (added columns in result table, * statements) |
74 | 78 | |
75 | | -$smwgIQMaxPrintout = 10; // Max number of supported printouts (added columns in result table, * statements) |
76 | | - |
77 | 79 | ### Formatting settings |
78 | | -$smwgIQDefaultLinking = 'subject'; // Default linking behaviour. Can be one of "none", "subject", "all" |
| 80 | +$smwgQDefaultLinking = 'subject'; // Default linking behaviour. Can be one of "none", "subject", "all" |
79 | 81 | |
80 | 82 | ## older query parameters below, some of those might be ignored |
81 | | -//$smwgIQMaxConditions = 50; // Max number of "conditions" (e.g. value or category conditions in a query) |
82 | | -//$smwgIQMaxTables = 10; // Max number of "joins" in a query. Restricts nesting depth of queries. |
83 | | -//$smwgIQSubQueriesEnabled = true; //(De)activates subqueries (<q>-Syntax), use $smwgIQMaxTables for limiting them |
84 | | -$smwgIQDisjunctiveQueriesEnabled = true; // Support disjunctions in queries (||)? |
85 | | -//$smwgIQRedirectNormalization = true; // Should redirects be interpreted as equivalence between page names? |
86 | | -$smwgIQSortingEnabled = true; // (De)activate sorting of results. |
| 83 | +//$smwgIQDisjunctiveQueriesEnabled = true; // Support disjunctions in queries (||)? |
87 | 84 | ## |
88 | 85 | |
89 | 86 | ### |