X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=docs%2Flinkcache.txt;h=266f200d48fad7113c7b64eedc86ed0d4c263bcd;hb=5860bf6c768a60e510bb21b95b089434ee4049f7;hp=ab36587d82a61f89a335a2cc3b780cd21a6584a1;hpb=380f4da60040ccf2fb5df6bb6ad58bad1bca9a9b;p=lhc%2Fweb%2Fwiklou.git diff --git a/docs/linkcache.txt b/docs/linkcache.txt index ab36587d82..266f200d48 100644 --- a/docs/linkcache.txt +++ b/docs/linkcache.txt @@ -1,31 +1,24 @@ linkcache.txt -The LinkCache class maintains a list of article titles and -the information about whether or not the article exists in -the database. This is used to mark up links when displaying -a page. If the same link appears more than once on any page, -then it only has to be looked up once. +The LinkCache class maintains a list of article titles and the information about +whether or not the article exists in the database. This is used to mark up links +when displaying a page. If the same link appears more than once on any page, +then it only has to be looked up once. In most cases, link lookups are done in +batches with the LinkBatch class, or the equivalent in Parser::replaceLinkHolders(), +so the link cache is mostly useful for short snippets of parsed text (such as +the site notice), and for links in the navigation areas of the skin. -In practice, what happens is that the global cache object -$wgLinkCache is consulted and updated every time the function -getArticleID() from Title is called. +The link cache was formerly used to track links used in a document for the +purposes of updating the link tables. This application is now deprecated. -This has a side benefit that we take advantage of. We have -tables "links" and "brokenlinks" which we use to do things -like the Orphans page and Whatlinkshere page. It just so -happens that after we update a page, we display it--and as -we're displaying it, we look up all the links on that page, -causing them to be put into the cache. That information is -exactly what we need to update those two tables. So, we do -something tricky when we update pages: just after the update -and before we display, we clear the cache. Then we display -the updated page. Finally, we put a LinksUpdate object onto -the deferred updates list, which fetches its information from -the cache. +To create a batch, you can use the following code: -There's a minor complication: displaying a page also looks up -a few things like the talk page link in the quick bar and the -date links. Since we don't want those in the link tables, we -must take care to suspend the cache while we look those up. -Skin.php does exactly that--see dateLink(), for example. +$pages = array( 'Main Page', 'Project:Help', /* ... */ ); +$titles = array(); +foreach( $pages as $page ){ + $titles[] = Title::newFromText( $page ); +} + +$batch = new LinkBatch( $titles ); +$batch->execute(); \ No newline at end of file