Extensions FAQ

How do I enable an extension?
Copy the extension PHP file to your extensions folder and add a require_once( "extensions/FILENAME" ); statement to your LocalSettings.php, with FILENAME being the filename of your extension, such as Extension.php.

See also Manual:Extensions

How do I write my own extension?
See Manual:Extensions.

How do I disable caching for pages using my extension?
The extension purgePage can also be used to perform the steps listed below, it works for MediaWiki 1.3 - 1.5.

For MediaWiki 1.3, include the following code in your extension:

For MediaWiki 1.4, use this (won't necessarily work in all cases):

Note: The above doesn't work in all cases. Using the same logic but with different code the following lines work much better. For MediaWiki 1.4 the following also works (possibly better than the above method):

In MediaWiki 1.5beta5, a more reliable interface was introduced. Your parser hook function may take a parser object as a third parameter, by reference. Use the following code: Note: on MediaWiki version 1.5.8 any of the above didn't work. You can see the following code functioning properly here. I had to use the following code in the second function of the extension (not the "setHook" function):

WARNING: In version 1.6 and many early versions of 1.7, it is impossible for extensions to prevent pages from being cached when edits are submitted. This is not expected behavior, see 5683. There are a number of ways to work around this issue:
 * Install the DisableCache hack. This is the most elegant solution, but has not been thoroughly tested.
 * Run action=purge after submitting edits. This is the safest choice, but may not be feasible in large wikis.
 * Disable caching site-wide. This will sharply increase the amount of work that your server will have to perform.  To disable all caching, put the following code in LocalSettings.php:

I would recommend using the php function date rather than a system call (system calls might be forbidden, date might be broken or some strange person could have the idea of running php on a windows server...

Recent versions
In MediaWiki 1.7.0 and upwards, the following should be sufficient:



where  is the reference to the parent parser that is passed as a third parameter to parser hook extensions.

Special pages
When rendering output that will not be subject to parser cache, such as on a special page

where $text is the wikitext to be parsed.

Parser hooks
See Manual:Tag extensions

How do I enable searching in my extension's output (dynamic content)?
You can't. Dynamic content can not be included in a static index.

How can I avoid modification of my extension's HTML output?
See Manual:Tag extensions

How can I pass XML-style parameters in my extension tag?
See Manual:Tag extensions

Extensions and Templates
See Manual:Tag extensions

"NaodW..." or "UNIQ..."
In previous version of MediaWiki, another problem with templates and extensions was the appearance of "NaodW..." or "UNIQ..." strings in the template output. MediaWiki 1.5(.1) has problems with some PHP versions which causes that output. You should upgrade to MediaWiki 1.5.2 or later.

Another clue is that your extension (or another one installed) might by using parse function instead of recursiveTagParse. Then change it to recursiveTagParse (using the parser given in parameter or $wgParser).

How can I determine in my extension, if an article is protected or not?
Use the Title class and the isProtected method, e.g.

What permissions do I apply to the extensions folder?
All the scripts in the /wiki structure need to be readable and executable by the user that PHP runs as. All perms are usually 755 and owner/group being a different user. The LocalSettings.php file is created by the script on setup and so will be an example to set the rest by.

How do I get my extension to show up on Special:Version?
See Manual:Extensions