Extension:MassEditRegex

From MediaWiki.org
Jump to: navigation, search

This extension allows administrators to perform a single edit across multiple pages in one step, by running a regular expression over the content of each page. This is well suited to performing simple edits such as renaming a template, adding pages to a category, or correcting typos (all of which can be done in the same edit operation by supplying multiple regular expressions.)

MediaWiki extensions manual - list
Crystal Clear action run.png
MassEditRegex

Release status: beta

MassEditRegex.png
Implementation Page action, Special page
Description Use regular expressions to edit multiple pages at once
Author(s) Adam Nielsen (Malvineoustalk)
Last version r5 (2011-11-30)
MediaWiki 1.14+ (<=r4), 1.18+ (r5), 1.19x-1.20
License GPL
Download
Check usage and version matrix

Contents

Usage [edit]

Once the extension has been installed and permission masseditregex to use MassEditRegex has been given, go to Special:MassEditRegex and fill out the edit form (see screenshot).

Features [edit]

  • Transform each page using one or more regular expressions in a single step
  • Edits appear as "bot" so they don't show up in the normal edit list (unless the user chooses to show bot edits)
  • Only users with the masseditregex permission can perform changes
  • Pages to edit can be specified as:
    • A list of page names
    • A list of page name prefixes (e.g. "Test" will match pages called "Testing" and "Tested")
    • A list of categories (all pages within the categories will be edited)
    • A list of backlinks (pages edited are those linking to the ones in the list)

Installation [edit]

Requirements [edit]

  • MediaWiki 1.14 or newer. This is required as earlier versions did not allow extensions to edit pages via the API. It should be possible to set $wgWriteAPI = true in some (later) versions of MediaWiki 1.13, however this has not been tested with recent versions so upgrading to 1.15 is recommended.

Download [edit]

Download the extension from the Subversion repository and save it into the extensions/MassEditRegex directory of your wiki. If you have shell access to your server, you may do the following to download the extension.

Warning: Before you download read Requirements or you might install the wrong version:

cd extensions
svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/MassEditRegex

Add the following to LocalSettings.php:

$wgEnableWriteAPI = true;  // Only required for MW earlier than version 1.14
require_once ( "$IP/extensions/MassEditRegex/MassEditRegex.php" );
$wgGroupPermissions['sysop']['masseditregex'] = true; // Allow administrators to use Special:MassEditRegex

Bugs / Known Issues [edit]

  • There was a security issue in r3 and earlier, which allowed users to run PHP code on the server with the /e modifier. This has been fixed in r4.
  • Editing is very slow on 1.14 and earlier (the MediaWiki API takes 2-3 seconds to edit each page.) This seems to be fixed in 1.15.
  • Depending on your webserver's PHP config, scripts may time out after 30 seconds or less. In this case you will need to check your contributions page to see which articles have been edited and remove those from the list before performing the edit again.
  • A large number of edits can exhaust the amount of memory allocated to PHP. This is because the code loads all pages into memory before starting to edit them. This needs to be rewritten to only load pages one at a time.

To do [edit]

This is a list of things planned for the extension that aren't currently there:

  • Put a link/button/tab on category pages to edit all pages in the category

Troubleshooting [edit]

  • If you can preview your changes but not apply them, make sure the MediaWiki write API is enabled.
  • If you get an error or a blank page when applying your edits, an error has probably occurred, most likely from trying to edit too many pages in one go. Until this is fixed, try splitting the edit into two or more smaller groups of pages.