Jump to content

Wikifunctions:Type proposals/Wikifunctions object reference

From Wikifunctions
Latest comment: 1 month ago by DVrandecic (WMF)
Done Implemented as Wikifunctions object reference (Z96) --DVrandecic (WMF) (talk) 14:04, 27 August 2026 (UTC)Reply

Summary

Follow the pattern used for the various Wikidata references (Z6091, for example) to provide safe (non-dereferencing) references to Wikifunctions objects as well.

Uses

Structure

Like Z6091, Wikifunctions object reference would be a wrapped string, with the string having the form of a Z9.

Example values

A reference to the type Z6001

{
  "type": "Wikifunctions object reference",
  "value": "Z6001"
}
{
  "Z1K1": "Z6090",
  "Z6090K1": "Z6001"
}

Validator

The validator ensures that:

  • The string value is a valid Z9

Identity

Two Wikifunctions object references are the same if their string values are equal.

A Wikifunctions object reference is equivalent to a Wikifunctions object if there is a Z2 whose Z2K1 is the same as the value of the Wikifunctions object reference and that Z2 has a value for its Z2K2 that is equivalent to the Wikifunctions object.

Converting to code

Python

Converts in the same way as Z6091 but there might be an explicit Z46 and Z64, if the type does not need to be built in.

JavaScript

Converts in the same way as Z6091 but there might be an explicit Z46 and Z64, if the type does not need to be built in.

Display function

Should be a simple string but can be displayed in the interface as the label of the referenced object (as currently) or as a link to the referenced object (as with Wikidata references)

Read function

Could be a simple string but the use of an object selector should be an option

Alternatives

The alternative is to make Z9 behave properly, but its behaviour would still be inconsistent with Wikidata reference objects, which will be more familiar to most users.

The validator could also ensure that there is a Z2 whose identity is the same string, but this would be inconsistent with the current approach for Wikidata references.

Z6090 is used here as an example, but it would be nice if we could actually use that value,

Comments

Might make fixing Z828 easier

The built-in function Z828 has issues described in phab:T366246 and phab:T366403 with improvements suggested in phab:T366459. Using a wrapped string for the required object reference rather than a quoted reference would probably make these issues easier to resolve. GrounderUK (talk) 22:12, 10 April 2025 (UTC)Reply

Also Error strings

If you’ve ever wondered why your error-message strings just vanish when they contain only a ZID, it’s because the ZID is taken to be a Reference, de-referenced to an object and then dropped for not being a string. This would still happen if a Wikifunctions object reference/identifier were unwrapped and it would also be dropped as a non-string if it were not. We should probably raise a Phabricator ticket for this, but it might be better deferred if unwrapping/reducing to a string could be a general feature of Wikifunctions.Error. GrounderUK (talk) 15:33, 16 July 2026 (UTC)Reply

Implementation started

We started implementing this Type as originally suggested, just with a single key string. As this is potentially becoming a basic type, we moved it to the built-in space, and so it needs to be deployed through code changes. You can follow the implementation here. --DVrandecic (WMF) (talk) 07:08, 13 August 2026 (UTC)Reply