Merge "Rewrite pref cleanup script"
[lhc/web/wiklou.git] / docs / deferred.txt
1 deferred.txt
2
3 A few of the database updates required by various functions here can be
4 deferred until after the result page is displayed to the user. For example,
5 updating the view counts, updating the linked-to tables after a save, etc. PHP
6 does not yet have any way to tell the server to actually return and disconnect
7 while still running these updates (as a Java servelet could), but it might have
8 such a feature in the future.
9
10 We handle these by creating a deferred-update object and putting those objects
11 on a global list, then executing the whole list after the page is displayed. We
12 don't do anything smart like collating updates to the same table or such
13 because the list is almost always going to have just one item on it, if that,
14 so it's not worth the trouble.
15
16 Since 1.6 there is a 'job queue' in the jobs table, which is used to update
17 link tables of transcluding pages after edits; this may be extended in the
18 future to more general background tasks.
19
20 Job queue items are fetched out of the queue and run either at a random rate
21 during regular page views (by default) or by a batch process which can be run
22 via maintenance/runJobs.php.
23
24 Currently there are a few different types of jobs:
25
26 refreshLinks
27 Used to refresh the database tables that store the links between pages.
28 When a page is changed, all pages using that page are also cleared by
29 inserting a new job for all those pages. Each job refreshes only one page.
30
31 htmlCacheUpdate
32 Clear caches when a template is changed to ensure that changes can be seen.
33 Each job clears $wgUpdateRowsPerJob pages (300 by default).
34
35 enotifNotify
36 Used to send mail using the job queue.