SemanticMediaWiki / SemanticScribunto

Provides service functions to support the Scribunto extension
Other
24 stars 14 forks source link

Object of class LuaSandboxFunction could not be converted to string when passing iterators into SMW objects #75

Closed FO-nTTaX closed 4 years ago

FO-nTTaX commented 4 years ago

Setup and configuration

Issue

When people create modules that save bad values into Semantic Objects, the calling page errors out as HTTP error 500. In the example someone tried to save an iterator into a property, which obviously does not work, getting an error 500 instead of an error message was not very obvious to them though. Returning an error message instead of a hard error 500 would probably be advisable.

Produces a stack trace and outputs:

PHP Recoverable fatal error:  Object of class LuaSandboxFunction could not be converted to string in /extensions/SemanticScribunto/src/ScribuntoLuaLibrary.php on line 363

Steps to reproduce the observation (recommendation is to use the sandbox):

Example Module:

local p = {}
function p.t()
    local dataStore = {}
    dataStore['some property'] = mw.text.gsplit('some','strings')
    mw.smw.set(dataStore)
    -- mw.smw.subobject(dataStore) -- this produces the same result
end
return p

and the module would simply be called as {{#invoke:Module name|t}}

Given it is easy to work around this by not passing broken things in, I do not think this is super urgent, but it might be a nice to have to catch such errors.

kghbln commented 4 years ago

@FO-nTTaX Thanks for reporting and suggesting. I agree that a more graceful failure will be preferable.

@oetterer FYI Probably you would like to have a go at it. :)