the || disjunction operator in semantic search breaks page
Closed, ResolvedPublic

Description

Author: info

Description:
Pages that use || in semantic searches return a blank page (0-length HTML, no
content).

This happened fairly recently on ontoworld.org.

It makes pages like http://ontoworld.org/wiki/Help:Category (an unofficial help
page) appear blank.

Yet the documentation
http://ontoworld.org/wiki/Help:Semantic_search#Wildcards_and_disjunctions says
that || is the right way to require a disjunction.

You can see it if you go to http://ontoworld.org/wiki/Special:Ask
and query for [[Born in::Dallas||Iceland]]

Remove one of the terms and it works.


Version: unspecified
Severity: major
URL: http://ontoworld.org/wiki/Special:Ask?query=[[Born in::Dallas||Iceland]]

bzimport set Reference to bz9178.
bzimport created this task.Via LegacyMar 6 2007, 6:15 AM
bzimport added a comment.Via ConduitMar 6 2007, 9:35 PM

info wrote:

On my local wiki, I get
Catchable fatal error: Object of class Title could not be converted to string in
C:\xampplite\htdocs\mediawiki\extensions\SemanticMediaWiki\includes\SMW_InlineQueries.php
on line 831

$check_titles = array_diff( $titles , array() ); // Copies the array

According to the doc at http://php.net/manual/en/function.array_diff,
array_diff() casts to string when comparing array entries, and this fails for
MediaWiki's Title objects.

I think this broke in revision 17529 when normalizeRedirects() switched from
working on article names to working on Title objects.

Maybe there's a better way to copy the $titles array with the desired behavior.
(I think array_unique() is a better function to use here and elsewhere than
array_diff() but it too casts to a string.)

Or, create a $check_title_article_ids array just with the title->getArticleID()s
and iterate through that; but the code is complex.
I think the code is also broken at line 850

		if (!array_key_exists( $id , $titles)) {

where it assumes a title's articleID is the key for title objects in an array.

A workaround is to disable redirect normalization by setting
$smwgIQRedirectNormalization = false; in the file.

mkroetzsch added a comment.Via ConduitApr 24 2007, 7:37 AM

I think I fixed this one for now (at least [[Born in::Dallas||Iceland]] works,
and I addressed the issue with title keys). Future versions will get a better
redirect handling.

Add Comment

Column Prototype
This is a very early prototype of a persistent column. It is not expected to work yet, and leaving it open will activate other new features which will break things. Press "\" (backslash) on your keyboard to close it now.