Page MenuHomePhabricator

getTripleList in SMWExpData creates blank nodes for values of 0. Possible fix included
Closed, ResolvedPublic

Description

Author: c_b_dvs

Description:
I've been debugging an issue where literal object values of zero are converted into blank nodes. The particular property for this object has units associated with it, although I doubt that this contributes to the bug.

I believe that the problem is in the check for blank nodes in the getTripleList function in SMW_Exp_Data.php. If I understand things correctly, then this line:
if ( ( $name == '' ) || ( $name[0] == '_' ) ) {

should be changed to this:
if ( ( $name === '' ) || ( $name[0] === '_' ) ) {

...so that it does not interpret 0 as an empty string.

Chris


Version: unspecified
Severity: normal

Details

Reference
bz27991

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:29 PM
bzimport set Reference to bz27991.

I did not replicate the setup, nor do I understand why $name would ever be 0 (as int or float), but I applied the suggested fix as I don't see how it could break intended behavior: https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Special:Code/MediaWiki/83694

c_b_dvs wrote:

I've found that $name can be 0 since in the code the name of the literal is just set to the value of the literal. In other words, in debugging this I've also seen floats, dates, coordinates, etc used as values for $name.

Right ok. Can you confirm your suggested change fixes the issue?

c_b_dvs wrote:

This fixes it. Thanks for updating the code.

Awesome, thanks for pointing out the fix :)