Wiki IDs are currently represented with a native union of string|false, where string is a full wiki ID, and false represent the local wiki. However, this leads to at least two separate issues:
- The local wiki can be represented as both false and its full string form, thus leading to ambiguity. In the best case scenario, this means that code will need to do normalization like if ( $stringID === $currentWikiID ) $wikiID = false, and code like this will be repeated in countless places. In the worst case scenario, something will forget to do the normalization and break, as I recently saw in T406777.
- The concept of wiki ID is sometimes confused with that of database domain (ID). This recently came up in T404118, later moved to core bug T405922. And there could possibly be more places where this confusion exists.
These issues could be partially resolved by introducing a new WikiID value object that would be passed around in place of the string|false union. The object itself could have getters to perform the normalization when needed, so that people don't need to repeat it everywhere. And hopefully, confusion with database domains should be less likely (although I guess nothing would prevent someone from instantiating a WikiID object with a database domain ID, but perhaps we can think of how to help avoid this mistake).
See also: T224020: Create a class to represent the identity of wikis on the same wiki farm