Page MenuHomePhabricator

mw.wikibase.getEntity(nil) returns an entity object on Flow page preview, but nil on page save
Open, Needs TriagePublic

Description

I copied the top wikitext from: https://www.wikidata.org/wiki/Wikidata:Property_proposal/Authority_control#catalog_prefix
and placed it in a flow post (and summary): https://www.wikidata.org/wiki/Topic:Stfrb1ho59tokf53
During preview, it says: Lua error in Module:Property_documentation at line 262: attempt to concatenate global 'id' (a nil value).
But it renders properly after I save. (Identically to the version in my sandbox, which works properly in both wikitext-preview and in visual editor edit-mode.).

Event Timeline

Quiddity created this task.Nov 26 2015, 6:39 PM
Quiddity updated the task description. (Show Details)
Quiddity raised the priority of this task from to Needs Triage.
Quiddity added a subscriber: Quiddity.
Restricted Application added a project: Collaboration-Team-Triage. · View Herald TranscriptNov 26 2015, 6:39 PM
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald Transcript

The direct cause of this error message is the logic in d:Module:Property documentation. On line 262 it assumes that the global variable id exists if the Wikibase entity returned by mw.wikibase.getEntity also exists on line 257. However, if no id is supplied as an argument to the module, the module is not invoked in the "Property talk" namespace, and mw.wikibase.getEntity(nil) returns the entity for the current page, then the id variable will be nil, and the Wikibase entity will exist. This will result in the error that you saw when the module tries to concatenate id to the URL string in line 262.

So, this is mostly a module coding error. However, this also means that mw.wikibase.getEntity(nil) returns an entity object on Flow page previews, but returns nil when the page is saved. So we should investigate why this happens and what the correct behaviour should be for Flow/Wikibase.

Restricted Application added a project: Wikidata. · View Herald TranscriptNov 27 2015, 8:52 AM
MrStradivarius renamed this task from Flow: A lua error during preview but not after saving to mw.wikibase.getEntity(nil) returns an entity object on Flow page preview, but nil on page save.Nov 27 2015, 8:57 AM

So, this is mostly a module coding error.

I saved some changes which I had already had prepared in the sandbox, no there is no global id.

hoo added a comment.Dec 27 2015, 10:01 AM

I looked at this briefly and the cause for this is pretty obvious:

During comment preview, the title being used (which is mw.title.getCurrentTitle() in Lua) is the title of the page you are on. But after saving, the title of the flow topic page in question is being used (which is some random(?) page in the Topic: namespace). I don't think there's anything we can do in Wikibase to "fix" this and I'm not sure Flow should mess with the title used for parsing either. It might be a good idea to also use a random Topic: namespace title during comment previews in flow, but despite of that, I don't think this is actionable. Wontfix?

I don't think there's anything we can do in Wikibase to "fix" this and I'm not sure Flow should mess with the title used for parsing either. It might be a good idea to also use a random Topic: namespace title during comment previews in flow, but despite of that, I don't think this is actionable. Wontfix?

If we knew the exact title in the Topic namespace that would be used on page save, then using that in the preview would be ideal. But I have no idea how the Flow architecture works, and whether this would be feasible.

hoo moved this task from Incoming to To do later on the Wikibase-Lua board.Apr 12 2018, 1:58 PM
Restricted Application added a project: Growth-Team. · View Herald TranscriptSep 2 2018, 10:09 AM