Last modified: 2008-06-08 15:26:19 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 13479 - the ~ "like" comparator doesn't work for many-valued properties
the ~ "like" comparator doesn't work for many-valued properties
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Markus Krötzsch
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-03-22 08:59 UTC by S Page
Modified: 2008-06-08 15:26 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description S Page 2008-03-22 08:59:21 UTC
Even if you enable the ~ comparator in $smwgQComparators in SMW_Settings.php,
querying a many-valued property for ~*partial* doesn't work.

For example, using ontoworld.org's [[Property:Employment]] and [[Einstein]] article
  [[Employment::?;~?atent*;?;?]]

doesn't find Einstein's "patent examiner" job.

The reason this doesn't work is that SMW_DV_NAry.php's prepareValue method doesn't match SMW_QueryProcessor.php's prepareValue method.  The latter compares $smwgQComparators and checks for case '~', the former hardcodes.

After copying code, the above example works in SMW 1.0.

Ideally the common code should be in a common function, but at least the code in each place should comment
   // The same code is in SMW_DV_NAry.php's prepareValue()
and vice-versa.
Comment 1 S Page 2008-06-06 07:52:52 UTC
Here's the "copying code" fix.

Index: C:/xampplite/htdocs/mediawiki/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php
===================================================================
--- C:/xampplite/htdocs/mediawiki/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php	(revision 33658)
+++ C:/xampplite/htdocs/mediawiki/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php	(working copy)
@@ -323,6 +323,7 @@
 	}
 
 	private function prepareValue(&$value, &$comparator, &$printmodifier) {
+		global $smwgQComparators;
 		// get print modifier behind *
 		$list = preg_split('/^\*/',$value,2);
 		if (count($list) == 2) { //hit
@@ -335,6 +336,7 @@
 			return;
 		}
 		$list = preg_split('/^(<|>|!)/',$value, 2, PREG_SPLIT_DELIM_CAPTURE);
+		$list = preg_split('/^(' . $smwgQComparators . ')/',$value, 2, PREG_SPLIT_DELIM_CAPTURE);
 		$comparator = SMW_CMP_EQ;
 		if (count($list) == 3) { // initial comparator found ($list[1] should be empty)
 			switch ($list[1]) {
@@ -350,8 +352,13 @@
 					$comparator = SMW_CMP_NEQ;
 					$value = $list[2];
 				break;
+				// The same code is in SMW_QueryProcessor.php's prepareValue()
+				case '~':
+					$comparator = SMW_CMP_LIKE;
+					$value = $list[2];
+				break;
 				//default: not possible
 			}
 		}
 	}
 
@@ -417,5 +424,15 @@
 		return; // not implemented yet
 	}
 
+	protected function getServiceLinkParams() {
+		// Simply concatenate each type's service link params.
+		$slps = array();
+		foreach ($this->m_values as $value) {
+			// I just want to append, PHP's array behavior is awful.
+			$slps = array_merge($slps, $value->getServiceLinkParams()); 
+		}
+		return $slps;
+	}
+
 }
 
Comment 2 Markus Krötzsch 2008-06-08 15:26:19 UTC
I now have made the function in SMWQueryParser static, so it can directly be called from the n-ary datavalue implementation.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links