Flow/Link table spec

We want to mimic MediaWiki behaviour with respect to links, templates and files. This is.

Requirements

 * Linking to a page or URL, including an image or a template, should cause entries to appear on Special:WhatLinksHere, Special:LinkSearch, and in usage lists for files.
 * In particular, including a file needs to add to the GlobalUsage tables.
 * It may need to be eventually possible to add a Flow board to a category.
 * It is very preferable that we can figure out exactly which post includes a link/file/template.

Implementation – Special:WhatLinksHere / Special:LinkSearch

 * Add a tracking table that associates links with Flow items (topics, posts, board headers).
 * When new links/templates/files are added to an (existing or old) post/header/topic, add them to both the Flow tracking tables and the ordinary MediaWiki ones.
 * When a post/header/topic is edited, and new links/templates/files are removed, remove them from the Flow tracking tables, and use those tables to determine whether or not to remove them from the standard MediaWiki tracking tables (i.e. remove them from those tables if no other references exist on the given Board.)
 * Add hooks to Special:WhatLinksHere and Special:LinkSearch, and, for results from Flow, use said hooks to add a direct link to the part of the Board which includes the link/template/file.

Other matters

 * Behaviour when files and templates are changed has not yet been determined at a product level. (See "Wikitext, extensions, and templates" in Flow/FAQ)
 * Red link / Blue link behaviour works correctly out of the box, because Flow resolves these at display time.
 * At this time Flow boards cannot be added to categories. (58197)

From Brad Jorsch comments in comment #22:
 * The list of pages using the file appears at the bottom of File-namespace pages.
 * There are also a number of API modules that query the existing links tables; there should at least be some way to
 * identify that a page is Flow
 * search these Flow-specific links tables to find the actual "thing(s)" doing the linking in the particular page.