Difference between revisions of "Find and replace text in an entire wiki"

From Organic Design wiki
m
(legacy)
 
Line 2: Line 2:
 
|description = Sometimes it's necessary to do global text replacements across an entire wiki, for instance if a company name changes, or a widely used word is found to be mis-spelled.
 
|description = Sometimes it's necessary to do global text replacements across an entire wiki, for instance if a company name changes, or a widely used word is found to be mis-spelled.
 
|role = sysop
 
|role = sysop
|status = in use
+
|status = legacy
 
}}__NOTOC__
 
}}__NOTOC__
  

Latest revision as of 11:21, 2 June 2010

Procedure.svg Find and replace text in an entire wiki
Organic Design procedure

Installing the script

Currently we have no in-wiki means of performing this task, so we use a dedicated Perl script called Caretaker.pl. The script should be run from the server hosting the wiki, and you should find it located in /var/www. If it's not there, you can create the file from the code in the wiki at caretaker.pl and you will also need to ensure that wiki.pl is in the same directory as the caretaker script.

Configuration

Before running the script you must edit it and set the configuration variables for the wiki URL (use long form) and the wiki user and password to do the editing as. The script uses a direct database connection to obtain the list of articles to process, so you also need to fill in the database name, table prefix and a database user and password (default is to use the same credentials as the wiki login).

Replacement rules

The replacement regular expressions must also be edited in the script in the clearly marked section near the middle.

Test and run

The script speed can be adjusted (by setting the value in the sleep call near the end) so that you can stop it after one or two changes and then check in the wiki whether it's doing the right thing and revert it if not. Once it's working fine, put the speed up to 0.1 or 0.2 and do the main run.