Jump to content

Extension:AdvancedBacklinks

From mediawiki.org
MediaWiki extensions manual
AdvancedBacklinks
Release status: beta
Implementation Database , Special page
Description Adds more backlink tracking capability to MediaWiki
Author(s) Ostrzycieltalk
Latest version 2.7.0
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.34+
PHP 7.2+
Database changes Yes
License GNU General Public License 2.0 or later
Download
Example Pages linking to an image on Nonsensopedia grouped by templates that include the image
  • $wgAdvancedBacklinksTrackExtlinks

The AdvancedBacklinks extension greatly extends MediaWiki's backlink tracking capability by tracking through what templates a page is linked to. It indexes wikilinks and imagelinks while preserving more information about them than MediaWiki's parser.

Its main purpose is to help with tracking backlinks on wikis that use navboxes or similar templates with large amounts of links. This extension can filter out backlinks that are added through templates and show the user only direct wikitext links. This has been a long-requested feature on Wikipedia and other wikis, see these three tasks on Phabricator for more details: T3392, T5241, T14396.

The extension also adds numerous other features to aid with redlink tracking, finding orphaned pages and more.

This extension is currently under active development lead by Nonsensopedia's community.

Installation

[edit]

Patch core

[edit]

This is a truly crazy extension, so it requires two new hooks deep in the parser to function: PPFrameBeforeExpansion and PPFrameAfterExpansion. The task to add them to MediaWiki core is T232305, you can find the relevant Gerrit patch there.

Keep in mind though, that this patch will never be merged into core and instead the extension will probably have to be reworked to rely on a completely different hook.

Install the extension

[edit]
  • Download and place the file(s) in a directory called AdvancedBacklinks in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'AdvancedBacklinks' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • Run the refreshLinks.php maintenance script to build the link index.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

[edit]
$wgAdvancedBacklinksTrackExtlinks
Whether to include external links to the same wiki (like [https://www.mediawiki.org/wiki/MediaWiki MediaWiki]) during indexing wikilinks. Default is true, which is consistent with default MediaWiki's behaviour.

Magic words

[edit]
[edit]

If you want a certain template not to appear in the transclusion tree on Special:AdvancedBacklinks, you can do so by placing a __DIRECTLINK__ magic word in that template. This will make the template transparent to the extension during indexing. One possible use case is templates for making a certain type of link easily, like colored links.

__REDLINKALLERGIC__

[edit]

This magic word is used to mark pages that should not contain any redlinks, i.e. links to non-existent pages. This can be useful for various lists, templates and reports.

Pages marked with the __REDLINKALLERGIC__ magic word can be later inspected on the Special:UndesiredRedlinks page.

__REDLINKALLERGICTHROUGH__

[edit]

Same as __REDLINKALLERGIC__, but applies to links going through the page. For example you can use it to find incorrectly used infoboxes or See also-type templates with redlinks in them.

Can be combined with __DIRECTLINK__.

__IGNOREORPHANED__

[edit]

In case you don't want a page to show up in the orphaned (lonely) pages reports (Special:LonelyPages, Special:WikitextLonelyPages and Special:WikitextContentLonelyPages), you can use this magic word to do so. This can be an alternative to the commonly used method of linking said pages on a single meta page.

__TRANSCLUSIONISNOTADOPTION__

[edit]

By default all LonelyPages reports will not list pages that are transcluded somewhere. You may not find it a desirable behavior in all situations, though. In such cases you can mark the transcluding page with this magic word to make the LonelyPages reports ignore it.

Special pages

[edit]
[edit]

A page that replaces Special:WhatLinksHere. The What links here link in sidebar is automatically changed to point to Special:AdvancedBacklinks. This special page exposes a very similar interface to that of Special:WhatLinksHere, but with a couple new features:

  • The ability to show only direct links from pages (in wikitext). That excludes all links that are transcluded by templates. To do that, please check the Wikitext links only option.
  • Links are displayed in a tree-like structure. Links that are transcluded through a template are shown as children of that template.
Example

Let's assume we have four pages on our wiki, A, B, C and D. We also have a template called Navbox that has a link to A in it. This template is transcluded by B and C. D has a direct link in wikitext to A.

What would Special:AdvancedBacklinks/A show?

  • D
  • Navbox (through transclusion)
    • B
    • C
[edit]

A report showing a list of redlinks on pages that should not contain them. To mark pages for being redlink allergic, you should use the __REDLINKALLERGIC__ magic word. This page also supports showing which templates transclude the undesired redlinks.

This an expensive special page, if you have $wgMiserMode enabled, it will be refreshed only with the updateSpecialPages.php script and its results will be cached.

There's also a ton of other special pages, not described yet.

Maintenance

[edit]

If you find in your database wikilinks or imagelinks from a nonexistent page, you can clean them up using the RemoveBrokenLinks.php script provided in the maintenance folder. Broken links can appear in the database after some kind of software failure or manual intervention. They should not appear during normal operation.

API

[edit]

TBD

See also

[edit]
  • Svetovid – an extension that uses the above and some black magic to allow for semi-automatic link creation.