Difference between revisions of "WikiDB/Maintenance scripts"

From TestWiki
Jump to: navigation, search
(RefreshStaleData.php: + another reason the script may need to be run)
m (RebuildWikiDB.php: Clarify purpose of the --wipefirst flag.)
 
Line 40: Line 40:
 
'''Arguments:'''
 
'''Arguments:'''
 
   --start          If specified, start from this article ID, rather than article 1.
 
   --start          If specified, start from this article ID, rather than article 1.
   --wipefirst      If specified, the whole cache is wiped first.  This is currently
+
   --wipefirst      If specified, the whole cache is wiped first.  This is
                   the only way to delete cached data for deleted articles.
+
                   the only way to remove deleted articles from the cache
 +
                  (though, under normal operation, deleted articles should be
 +
                  automatically removed).
 
   --skip-refresh  Bypasses the code which updates any stale records created due to
 
   --skip-refresh  Bypasses the code which updates any stale records created due to
 
                   data definitions changing.
 
                   data definitions changing.

Latest revision as of 21:43, 30 March 2019

This page describes the available maintenance scripts for WikiDB.

The scripts can be run by going into the maintenance directory via the command-line and running PHP with the name of the script.

For example:

$ cd /path/to/mediawiki/extensions/WikiDB/maintenance
$ php ScriptName.php args

You will need to replace the /path/to/mediawiki/extensions/ with the appropriate path on your system, and ScriptName.php should be replaced with the name of the script to run (as described below). If the script has any arguments they should follow the script name, as indicated by args, above. Not all scripts have arguments.

The standard MediaWiki command-line options may also be applicable. See mw:Manual:Maintenance scripts for more information about running command-line scripts for MediaWiki.

SetupTables.php[edit]

Purpose: Installer for the WikiDB table structure. This script installs the tables required for the WikiDB extension, and will also update any existing installations if the table structure has changed between versions. It does not populate the tables at all, as this can be very time-consuming and may not be required in all instances. Note that in this sense, we are referring to the core MediaWiki tables that store the data for your wiki - not the in-wiki tables that WikiDB provides!

When to run it: You need to run it when you first install WikiDB, in order to set up the tables properly. You will also need to run it when you upgrade if the release notes indicate that the WikiDB table schema has changed. This will only be the case if the major version number has changed - minor version number changes will never require a DB update. It is always safe to re-run this script - it will only make changes if they are required.

UpdateTableNS.php[edit]

Purpose: Rebuilds the wikidb_tabledata table, which holds the parsed field definitions for all pages located in a table namespace (as defined by $wgWikiDBNamespaces).

When to run it: You should run this script whenever you add or remove a table namespace (i.e. when you modify $wgWikiDBNamespaces). Call it with the IDs of any namespaces that have been added or removed from the array, separated by spaces. You can specify all to rebuild all table namespaces, but this is slow and should only be necessary if a WikiDB upgrade specifies that it is required. Note that you don't need to run this script if you are also going to run RebuildWikiDB.php, as that script updates all namespaces, including the table namespaces.

Arguments:

 space separated list of namespace IDs that you want to update.
 Alternatively, use 'all' (without quotes) to update all namespaces.
 --skip-refresh   Bypasses the code which updates any stale records created due to
                  data definitions changing.

RebuildWikiDB.php[edit]

Purpose: To rebuild the cached WikiDB data, by re-parsing all articles in the wiki. Because of this it can be very slow, particularly on large databases!

When to run it: Needs to be run when you first install WikiDB to a wiki with existing data (not required when installing on a brand new, empty wiki). Also required if a WikiDB upgrade indicates that the database will need to be rebuilt (e.g. if the parsing rules have changed). It is also the first recommendation if you are experiencing unexpected or missing data on your wiki after upgrading MediaWiki or installing new parser-related extensions.

Arguments:

 --start          If specified, start from this article ID, rather than article 1.
 --wipefirst      If specified, the whole cache is wiped first.  This is
                  the only way to remove deleted articles from the cache
                  (though, under normal operation, deleted articles should be
                  automatically removed).
 --skip-refresh   Bypasses the code which updates any stale records created due to
                  data definitions changing.

RefreshStaleData.php[edit]

Purpose: Field data can go stale if the the table definition they belong to gets updated. This is because we do not automatically update all data when the table changes, because for tables with a lot of data this would grind the wiki to a halt. Instead, when a table definition changes, we mark all affected rows as stale and then update them in batches on each page request. This script allows you to manually update stale records from the command-line.

When to use: If you have made a change to a table definition which has a large amount of data, it may take a long time for the changes to propagate to all data rows. In those cases you should run this script manually to update all stale data. The script is also designed to be run as a regular cron job, as an alternative to batch-updating the stale data on each page request. See $wgWikiDBMaxRefreshRate for more details about this. Note that if you run either UpdateTableNS.php or RebuildWikiDB.php without specifying the --skip-refresh option then this script is run automatically.

It may also be necessary to run this script, with the --force option, if the FormatForSorting code has changed for any data-type handlers installed on the wiki, to makes sure the data matches the current sorting rules.

Arguments:

 --report      This simply reports the number of stale records and exits.
 --limit=N     Allows you to perform a batch update of N revisions.  If omitted
               then all stale data is updated.  This switch is useful if you
               run the script via a regular cron-job and want to avoid 
               excessive load.
 --force       Marks all rows in the DB as stale prior to performing the
               refresh.  This is useful in situations where neither table data
               nor article data needs to be reparsed, but where we want to
               rebuild the field table, for example if the FormatForSorting
               code has changed for an existing data type.