r23317 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23316‎ | r23317 | r23318 >
Date:10:12, 24 June 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Disable subqueries for fixed subjects (unneeded nesting capability justcomplicates queries)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -574,37 +574,26 @@
575575 //$innerdesc = NULL;
576576 while ($continue) {
577577 $hasNamespaces = true; // enforced for all cases
578 - /// NOTE: this general enforcing is suboptimal for things like
579 - /// "<ask>[[<q>[[Category:A]]</q>]] [[Category:B]]</ask>"
580 - /// where one should have a single outer restriction and not enforce NS in the subquery.
581 - /// But this only works if all "fixed subjects" have no NS already. It would be a problem
582 - /// in cases like "<ask>[[<q>[[Category:A]]</q>||User:C]] [[Category:B]]</ask>". Since we
583 - /// cannot go back to get the NS-restriciton into the subquery here, we ignore the first
584 - /// case even though it is quite possible (think of many disjuncted subqueries).
585 - switch ($chunk) {
586 - case '<q>': // subquery
587 - $this->pushDelimiter('</q>');
588 - $setsubNS = true;
589 - $result = $this->addDescription($result, $this->getSubqueryDescription($setsubNS), false);
590 - break;
591 - default:
592 - $list = preg_split('/:/', $chunk, 3); // ":Category:Foo" "User:bar" ":baz" ":+"
593 - if ( ($list[0] == '') && (count($list)==3) ) {
594 - $list = array_slice($list, 1);
595 - }
596 - if ( (count($list) == 2) && ($list[1] == '+') ) { // try namespace restriction
597 - global $wgContLang;
598 - $idx = $wgContLang->getNsIndex($list[0]);
599 - if ($idx !== false) {
600 - $result = $this->addDescription($result, new SMWNamespaceDescription($idx), false);
601 - }
602 - } else {
603 - $title = Title::newFromText($chunk);
604 - if ($title !== NULL) {
605 - $result = $this->addDescription($result, new SMWNominalDescription($title), false);
606 - }
607 - }
 578+ if ($chunk == '<q>') { // no subqueries of the form [[<q>...</q>]] (not needed)
 579+ $this->m_error = 'Subqueries not allowed here.'; //TODO
 580+ return NULL;
608581 }
 582+ $list = preg_split('/:/', $chunk, 3); // ":Category:Foo" "User:bar" ":baz" ":+"
 583+ if ( ($list[0] == '') && (count($list)==3) ) {
 584+ $list = array_slice($list, 1);
 585+ }
 586+ if ( (count($list) == 2) && ($list[1] == '+') ) { // try namespace restriction
 587+ global $wgContLang;
 588+ $idx = $wgContLang->getNsIndex($list[0]);
 589+ if ($idx !== false) {
 590+ $result = $this->addDescription($result, new SMWNamespaceDescription($idx), false);
 591+ }
 592+ } else {
 593+ $title = Title::newFromText($chunk);
 594+ if ($title !== NULL) {
 595+ $result = $this->addDescription($result, new SMWNominalDescription($title), false);
 596+ }
 597+ }
609598
610599 $chunk = $this->readChunk();
611600 if ($chunk == '||') {

Status & tagging log