Page MenuHomePhabricator

Improve language fallback loop detection
Closed, ResolvedPublic

Description

The current language fallback loop detection code (in languages/Language.php) actually doesn't detect a loop, but rather stops a fallback chain when it gets larger than 5 items. It would be more logical (and more flexible) to keep track of what languages have been "visited" and break the loop if we return to one of them. In any case, it wouldn't be possible to build an infinite chain of unique language codes, so no arbitrary limit to feedback chains needs to be enforced.


Version: unspecified
Severity: enhancement

Details

Reference
bz30216

Related Objects

StatusSubtypeAssignedTask
ResolvedNikerabbit
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 21 2014, 11:52 PM
bzimport set Reference to bz30216.
bzimport added a subscriber: Unknown Object (MLST).

I think this doesn't actually block 30217, since the current mechanism would allow such a fallback loop to work (actually, it'd be treated as a chain and would be cutoff after 5 iterations, in case none of the localizations exist).

Except that the cutoff is an exception which halts code execution :/

Created attachment 8890
Proposed patch

Here is patch that makes the fallbacks a flat list instead of recursive chains. This way we avoid the problems with cycles, because we don't have them anymore.

Not included in the patch: updating $fallback in message files nor updating callers of getFallbackFor (which I plan to deprecate, perhaps with some heuristics to avoid causing loops for callers)

Attached: