How does Wikipedia update ages?

There are over a million pages in Wikipedia which are biographical articles of living people. (Which is an astonishing number.) A standard feature in such an article is to show the subject’s current age.

A little math shows that this means around three thousand edits a day would be necessary to update ages as people have a birthday. Obviously this is not being done by direct edits.

So I assume there must be some automated system that notes today’s date and is able to search all biographical articles for people with that birthday and add one to their age. Is this correct?

Is this all done at one time? Or is it a rolling process depending on time zones?

Are there other similar automated editing systems that I haven’t noticed?

It’s probably done by a little JavaScript program that’s part of the page and makes your browser compute the age. The computation is done by your local computer or phone, not by Wikipedia’s servers.

The article itself doesn’t have to be edited at all. There’s a template that automatically generates the age every time the page is loaded.

Interesting. I always assumed the text was there waiting, not generated when somebody opens the article.

So moving on to my other question, are there other examples of text that is generated like this when an article is opened?

There are many such computations.

Here’s one example: When you see something like “10 miles (16 kilometers)”, the “10 miles” is in the text of the wiki page’s contents. But what’s next in that text is an instruction to convert that value to km, round it appropriately, and display the result.

Likewise the details of references, footnotes, see alsos, are all computed on the fly. What you see is nowhere near what is stored.


Moving up a level …
It is really incorrect to think of any webpage anywhere since about 2001 as just a bunch of text sent to your browser for display. Every page on every website is actually a computer program in and of itself which includes a bunch of boilerplate human readable text, and lots of instructions for computation done on the server when the page is requested and before it is sent, then lots more instructions for computation done in the client after the page is received.

Look at the upper right corner of this post. The number or date will be recalculated every time you press refresh.

The constant refreshing of content is also why - for academic and legal purposes - you should be citing exactly when you accessed a page and, ideally, saving a screenshot of the document, because it might say something different after you come back from lunch.

I had assumed that Wikipedia was mostly an exception because of its open editing. It’s one thing to let anybody rewrite text. But letting people rewrite a program seems too trusting to me.

They don’t let just anyone rewrite the program, just a set of inputs to the program. A rather complicated set of inputs, but not enough so to enable really serious exploits.

Wikipedia actually has a page about this: Wikipedia:Age calculation templates - Wikipedia

These templates and their code don’t actually run on your computer; they are written in the Lua scripting language and run on Wikipedia’s own servers, where they generate plain HTML that your browser then renders. Here is a list of the templates that use this scripting language: Category:Lua-based templates - Wikipedia

The most sensitive templates are protected and editable by only special users, like administrators. e.g. Information for "Module:Citation/CS1" - Wikipedia is admin-only. Anybody can see the source code, but if you try to edit it, you’ll get a warning:

So if I’m understanding correctly, the Wikipedia programmers have designed the program so that there are pre-existing commands that can be used. Regular users off the street like me can insert these pre-designated commands into our edits (along with text) but we can’t rewrite the program itself.

Basically, yes.

Of course, this does require the programmers to be careful, because if they’re not, clever users can cause things to leak through. Though Wikipedia’s programmers probably were careful, given that they’ve been a big, high-profile target for a very long time and (so far as I know) no attacker has ever succeeded at something like that.

You can, to a degree. See Extension:Scribunto/Lua reference manual - MediaWiki and you can try it at Module:Module sandbox - Wikipedia

The Lua they use is modified and sandboxed with some built-in protections: LuaSandbox - MediaWiki

This is not an entirely uncommon use case; many PC games, for example, allow user-created extensions in Lua, sometimes even distributed on the official game’s plugins marketplace or on Steam.

Vandalism of any sort on Wikipedia is always a possibility, but:

  1. Their Lua has built-in safeguards, like stopping scripts after 7 seconds.
  2. It runs on Wikipedia servers, not your computer, so risk is mostly limited to their systems and not yours. By the time it gets to you, it’s just plain HTML.
  3. There are armies of robots and editors patrolling pages, especially popular ones, looking out for this and other types of vandalism

I think the TLDR is “yes, you can make some computer code run on Wikipedia, but it’s limited in the amount of damage it can cause, and especially important pages/modules are limited to certain classes of editors & admins anyway”.

I have added birth dates to a couple of Wikipedia pages, and when you.do that it calculates the difference from the current date to show the age. Pretty basic stuff, though I have wondered about Leap Days and other special calendar skips, if they are considered for those kinds of calculations.

I always did find it impressive that Rossini wrote The Barber of Seville at age six.

Server-side scripting with LUA (instead of client-side with JavaScript) makes a lot of sense for Wikipedia in particular. Everyone sees the same content regardless of OS, browser, JavaScript implementation, search engine crawling vs. human, etc.

Wikipedia still caches the articles so a popular page is not being constantly generated.