Manual:RefreshLinks.php

Details
refreshLinks.php file is a maint-scripts>Special:MyLanguage/Manual:Maintenance scripts|maintenance script to [re]fill pagelinks, categorylinks, imagelinks tables. You should run it if you found that Categories are empty or don't show all pages, if "What links here?" doesn't work well or in some other link-related trouble. Additionally this script purges those links, which point to non-existing pages, from the tables pglinks>Special:MyLanguage/Manual:pagelinks table|pagelinks, imglinks>Special:MyLanguage/Manual:imagelinks table|imagelinks, catlinks>Special:MyLanguage/Manual:categorylinks table|categorylinks, templatelinks>Special:MyLanguage/Manual:templatelinks table|templatelinks, extlinks>Special:MyLanguage/Manual:externallinks table|externallinks, iwlinks>Special:MyLanguage/Manual:iwlinks table|iwlinks, langlinks>Special:MyLanguage/Manual:langlinks table|langlinks, redirect>Special:MyLanguage/Manual:redirect table|redirect, and pgprops>Special:MyLanguage/Manual:page props table|page_props.

Invocation
 php maintenance/refreshLinks.php [starting_article]

for example, if you want the script to start with the page with id 8000:

 php maintenance/refreshLinks.php 8000

Advanced Usage
 php refreshLinks.php [--conf|--dbpass|--dbuser|--dfn-only|--e|--globals|--help|--m|--new-only|--old-redirects-only|--quiet|--redirects-only|--wiki]

Parameters
This also supports the cmdOptions>Special:MyLanguage/Manual:Maintenance_scripts#Standard command-line options|common options as well.

Avoiding memory issues
This script may run into memory issues. To avoid this you may like to set a last page_id to refresh.

 php refreshLinks.php --e 1500

To do the next set of page_ids you enter

 php refreshLinks.php -- 1500 --e 3000

Just continue until all page ids in your wiki were refreshed.

If you forgot to set a last  to refresh and the script runs out of memory simply rerun it with the last output   as the article to start at, e.g.

<pre style="overflow:auto;"> php refreshLinks.php -- 1600