Roan Kattouw wrote:
On Fri, Sep 23, 2011 at 11:52 PM, PlatonidesPlatonides@gmail.com wrote:
Maybe we should provide a way to generate namespaces for extensions. The simplest way, using a global which is updated by each extension reserving a namespace is too fragile, but maybe we could produce something similar to ftok(3) to derive a free namespace number.
TimedMediaHandler tried to do this (it picked the lowest free namespace number above 100 or something), and I made Michael take it out. The reason was that variable namespace numbers are very, very, bad:
- It will usually result in the same namespace having different
numbers on different wikis
- If you add site-specific namespaces or install another extension
using the same technique, the namespace number may change and all your pages will be messed up
Roan
Well, that's why I said that a simple approach wouldn't work. Compare the conflict of for ($i = 100; ; $i++) if (!isset($namespaces[$i]) return $i;
with an approach like
$name = 'TimedMediaHandler'; do { $name = md5($name); $n = 100 + hexdec(substr($name, -2)); } while (isset($namespaces[$n])); return $n;