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.
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.
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.
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.
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.
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:
Their Lua has built-in safeguards, like stopping scripts after 7 seconds.
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.
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.
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.