r24059 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24058‎ | r24059 | r24060 >
Date:12:06, 13 July 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Support for various further parameters to control/restrict query behaviour.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -283,6 +283,7 @@
284284 * The call-by-ref parameter $label is used to append any label strings found.
285285 */
286286 protected function getSubqueryDescription(&$setNS, &$label) {
 287+ global $smwgQPrintoutLimit;
287288 $conjunction = NULL; // used for the current inner conjunction
288289 $disjuncts = array(); // (disjunctive) array of subquery conjunctions
289290 $printrequests = array(); // the printrequests found for this query level
@@ -369,8 +370,15 @@
370371 }
371372 $setNS = $mustSetNS; // NOTE: also false if namespaces were given but no default NS descs are available
372373
 374+ $prcount = 0;
373375 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+ }
375383 }
376384 return $result;
377385 }
@@ -800,7 +808,13 @@
801809 } elseif ($conjunction) { // make new conjunction
802810 return new SMWConjunction(array($curdesc,$newdesc));
803811 } 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+ }
805819 }
806820 }
807821 }
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -612,15 +612,11 @@
613613 /**
614614 * The SQL store's implementation of query answering.
615615 *
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)
620616 * TODO: we now have sorting even for subquery conditions. Does this work? Is it slow/problematic?
621617 * NOTE: we do not support category wildcards, as they have no useful semantics in OWL/RDFS/LP/whatever
622618 */
623619 function getQueryResult(SMWQuery $query) {
624 - global $smwgIQSortingEnabled;
 620+ global $smwgQSortingSupport;
625621
626622 $db =& wfGetDB( DB_SLAVE );
627623 $prs = $query->getDescription()->getPrintrequests(); // ignore print requests at deeper levels
@@ -640,7 +636,7 @@
641637 $sql_options = array();
642638 $sql_options['LIMIT'] = $query->getLimit() + 1;
643639 $sql_options['OFFSET'] = $query->getOffset();
644 - if ( $smwgIQSortingEnabled ) {
 640+ if ( $smwgQSortingSupport ) {
645641 $order = $query->ascending ? 'ASC' : 'DESC';
646642 if ( ($this->m_sortfield == false) && ($this->m_sortkey == false) ) {
647643 $sql_options['ORDER BY'] = "$pagetable.page_title $order "; // default
@@ -955,6 +951,7 @@
956952 global $wgDBname, $smwgQSubpropertyDepth;
957953
958954 $tablename = 'prop' . SMWSQLStore::$m_tablenum++;
 955+ $this->m_usedtables[] = $tablename;
959956 $db->query( 'CREATE TEMPORARY TABLE ' . $tablename .
960957 '( title VARCHAR(255) NOT NULL )
961958 TYPE=MEMORY', 'SMW::getPropertyTable' );
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php
@@ -28,11 +28,11 @@
2929 * that may influence the processing details.
3030 */
3131 public function SMWResultPrinter($format, $inline) {
32 - global $smwgIQDefaultLinking;
 32+ global $smwgQDefaultLinking;
3333 $this->mFormat = $format;
3434 $this->mInline = $inline;
35 - $this->mLinkFirst = ($smwgIQDefaultLinking != 'none');
36 - $this->mLinkOthers = ($smwgIQDefaultLinking == 'all');
 35+ $this->mLinkFirst = ($smwgQDefaultLinking != 'none');
 36+ $this->mLinkOthers = ($smwgQDefaultLinking == 'all');
3737 $this->mLinker = new Linker(); ///TODO: how can we get the default or user skin here (depending on context)?
3838 }
3939
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php
@@ -62,27 +62,24 @@
6363 $smwgQSubpropertyDepth = 10; // Restrict level of sub-property inclusion (steps within property hierarchy)
6464 // (Use 0 to disable hierarchy-inferencing in queries)
6565 $smwgQEqualitySupport = true; // Should #redirects be evaluated as equality between page names?
 66+$smwgQSortingSupport = true; // (De)activate sorting of results.
6667 $smwgQDefaultNamespaces = array(NS_MAIN, NS_IMAGE); // Which namespaces should be searched by default?
6768 // (value NULL switches off default restrictions on searching -- this is faster)
6869 $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!)
6973
70 -
7174 ### Settings about printout of (especially inline) queries:
7275 $smwgQDefaultLimit = 50; // Default number of rows returned in a query. Can be increased with <ask limit="num">...
7376 $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)
7478
75 -$smwgIQMaxPrintout = 10; // Max number of supported printouts (added columns in result table, * statements)
76 -
7779 ### 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"
7981
8082 ## 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 (||)?
8784 ##
8885
8986 ###

Status & tagging log