Page MenuHomePhabricator

SMW: [[Corresponds to::0 xxx]] causes divizion by zero, internal error message and PHP stack dump
Closed, ResolvedPublic



`[[Corresponds to::0 xxx]]' causes error message:

Warning: Division by zero in /var/www/ocw/mediawiki-1.17.1/extensions /SemanticMediaWiki/includes/datavalues/SMW_DV_Quantity.php on line 30

and `Special:Internal error' with stack backtrace:

Initialisation value '' is not a number.


#0 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Quantity.php(30): SMWDINumber->__construct(false, '_qty')
#1 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Number.php(110): SMWQuantityValue->convertToMainUnit(1, '????????')
#2 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/datavalues/SMW_DataValue.php(169): SMWNumberValue->parseUserValue('1 ????????')
#3 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php(113): SMWDataValue->setUserValue('1 ????????', false)
#4 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php(177): SMWDataValueFactory::newTypeIdValue('_qty', '1 ????????', false, Object(SMWDIProperty), Object(SMWDIWikiPage))
#5 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/SMW_ParseData.php(113): SMWDataValueFactory::newPropertyObjectValue(Object(SMWDIProperty), '1 ????????', false, Object(SMWDIWikiPage))
#6 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php(165): SMWParseData::addProperty('Time to search', '1 ????????', false, Object(Parser), true)
#7 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php(112): SMWParserExtensions::parsePropertiesCallback(Array)
#8 [internal function]: SMWParserExtensions::simpleParsePropertiesCallback(Array)
#9 /var/www/ocw/mediawiki-1.17.1/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php(71): preg_replace_callback('/\[\[ ...', Array, '?* [[Time to se...')
#10 [internal function]: SMWParserExtensions::onInternalParseBeforeLinks(Object(Parser), '?* [[Time to se...', Object(StripState))
#11 /var/www/ocw/mediawiki-1.17.1/includes/Hooks.php(158): call_user_func_array(Array, Array)
#12 /var/www/ocw/mediawiki-1.17.1/includes/parser/Parser.php(1005): wfRunHooks('InternalParseBe...', Array)
#13 /var/www/ocw/mediawiki-1.17.1/includes/parser/Parser.php(283): Parser->internalParse('<!-- * [[Time t...')
#14 /var/www/ocw/mediawiki-1.17.1/includes/EditPage.php(1939): Parser->parse('<!-- * [[Time t...', Object(Title), Object(ParserOptions))
#15 /var/www/ocw/mediawiki-1.17.1/includes/EditPage.php(1218): EditPage->getPreviewText()
#16 /var/www/ocw/mediawiki-1.17.1/includes/EditPage.php(437): EditPage->showEditForm()
#17 /var/www/ocw/mediawiki-1.17.1/includes/EditPage.php(296): EditPage->edit()
#18 /var/www/ocw/mediawiki-1.17.1/includes/Wiki.php(522): EditPage->submit()
#19 /var/www/ocw/mediawiki-1.17.1/includes/Wiki.php(69): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#20 /var/www/ocw/mediawiki-1.17.1/index.php(114): MediaWiki->performRequestForTitle(Object(Title), Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
#21 {main}

Zero value for `Corresponds to' is a user mistake, but it should not cause SMW internal error with PHP stack dump.

BTW, I faced with problem by a mistake. I wrote [[Corresponds to::0.001 km]]'. Looks pretty good, doesn't? But MW content language specifies decimal separator as comma, so 0.001 km' is parsed as number 0' and unit .0001 km'. However, no warning or errors are show on property page. Instead, it causes stack dump on another page…

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:07 AM
bzimport set Reference to bz32594.
bzimport added a subscriber: Unknown Object (MLST).

Yeah... SMW should drop Corresponds to 0 values and show a warning that it's doing this.

Fixed in r111248. A warning is not shown though. I don't think this is really necessary in practice. wrote:

Guys, I spend noticeable part of my life hunting for the bugs in software. I *know* -- good error messages and warnings are REALLY NECESSARY!

Look into the case again:

[[Corresponds to::0.001 km]]

It looks perfect! Trouble appears in another page. It was PHP exception before, not to good, but at least it was the obvious signal that something goes wrong.

Now you *silently* ignore it, so users will spend hours trying to understand why `Corresponds to' DOES NOT WORK. They will be frustrated, they will apply for help, send messages to Semediawiki-user, and other people will spend time again... Why?

Ok, why do you show warnings if property value is invalid? For example:


(where property Coordinates' is of type Geographic coordinate') will show small yellow triangle with exclamation sing and bubble "Failed to parse geographic coordinate: foo"?

This is exactly the same case! User set property Corresponds to' to value which is not understood. Why invalid value of Coordinates' property shows warning, but `Corresponds to' -- does not?

If you think it is not really necessary, let us drop all the warnings.