User:DCrazy/Force Static

In response to WP:AUM, there has been much debate as to how to allow the features afforded by templates such as user wikipedia and Wikipedia:Babel while reducing server stress. Templates such as user wikipedia are referred to as meta-templates because they act as a shell for including other templates.

The problem with meta-templates is that changing them or the templates they include causes massive server stress, and their versatility begets wide adoption, thus making them large targets for vandalism (which will invoke even more server stress). For example, if page X includes, and Template:Y subsequently includes  , then changing any of Template:A, Template:B, or Template:C will force every page that includes Template:Y to be recached. Conditional templates such as qif compound this problem immensely due to their wide adoption and complexity (imagine if someone changed Template:qif — every single template that uses  would be recached!).

I proposed a solution on the talk page that I referred to as __FORCE_SUBST__, but after discussion would be more properly named __FORCE_STATIC__. The following observations arose out of the discussion:


 * Meta-templates are handy.
 * Many templates that could (and some probably should) be substituted using the syntax  aren't.  For example, locale length and tl.
 * Substitution of these templates reduces the strain caused by changing a template included by a meta-template.

Originally, __FORCE_SUBST__ would have added an option to templates such as Template:tl that, by means of including the __FORCE_STATIC__ keyword in the template, would automatically convert any instance of  to behave as if it were included as. Unfortunately, experimentation revealed that subst: merely inserts the source of the included template into the including page. This means that for templates such as Template:Locale length, a gigantic parameter reference would be included in the page, instead of merely the appropriate Imperial measurement. For Template:user wikipedia, this would mean a scores-of-kilobytes inclusion in a user page. While some people have lots of userboxes, no user page has need for all the ones afforded by Template:user wikipedia, so why store them there?

So I have changed my proposal to __FORCE_STATIC__. Instead of merely subst'ing the template, a template that includes the __FORCE_STATIC__ keyword would instead be pre-rendered, using any parameters provided. This has one unfortunate side-effect: variables such as CURRENTDAY could not be used as parameters to forced-static templates ( would result in a page that only showed information based on the CURRENTDAY variable as of the time the template reference was added). Templates that rely on this behavior cannot be made forced-static.

More importantly is what happens in the case of accidents or vandalism: if Template:X is forced-static, and is vandalized or otherwise unintentionally/destructively edited, and  is added to a page before Template:X is reverted, the edit cannot be reverted, since its end result has already been made plaintext in the page, and there is no link between it and the template anymore.

This problem cannot be avoided, but it can be mitigated. The best solution in my mind is two-staged.


 * 1) Block anons from editing the Template namespace. A quite controversial move that is currently being hashed out.
 * 2) Restrict use of __FORCE_STATIC__ to admins. They are much more likely to follow consensus and policy than normal users, and as such, given a good guideline, will try to avoid forcing-static pages that should not be forced-static.


 * Edit: Perhaps a better solution is to tie __FORCE_STATIC__ to an admin-only protection level. Then only forced-static templates are affected, and since these should be small, unchanging templates like welcome and locale length, the protection level shouldn't bother anyone.  It's not that hard to ask an admin to make the change anyway. --DCrazy talk/contrib 23:24, 17 January 2006 (UTC)

So the problem with meta-templates is twofold. Technologically, they are a potential server nightmare and even DoS vector, if someone changes a template that is included by a popular meta-template. Also, they are a nice target for vandalism. The implementation of __FORCE_STATIC__ solves the first issue, but only through proper implementation can the second be fixed.

--DCrazy talk/contrib 20:57, 17 January 2006 (UTC)