Extension:AssertEdit
|
AssertEdit Release status: stable |
|||
|---|---|---|---|
| Implementation | Page action | ||
| Description | Adds edit assertions, for safer bot edits. | ||
| Author(s) | Steve Sanbeg | ||
| Last version | 2008-01-31 (2008-01-31) | ||
| MediaWiki | 1.12a+ | ||
| License | GPL 2.0 or later [1] | ||
| Download | |||
|
|||
|
|||
| Check usage and version matrix; stats | |||
| Bugs: list open list all report | |||
- Help your bots to help your wiki.
When I started working with bots, I realised the potential for a simple operator error to make a lot of bad edits; such as a bot intended to run on a test wiki accidently running on wikipedia, because someone forgot to supply the -family option. It also happens that a bot may get logged out, and unknowingly continue editing anonymously, without the bot flag, until it's blocked.
It's not easy for a bot to determine whether it is logged in, without some server side support. Unfortunately, no such support was available, until now.
Contents |
Usage[edit]
To use the extension, supply an additional parameter -- either assert or nassert -- when editing a page, whether through the UI (index.php) or API (api.php).
The value of the assert (or nassert) parameter should be the desired assertion. If it succeeds, the extension does nothing, and the edit proceeds as normal; if it fails, an error message is returned. assert ensures that assertion is positive, while nassert ensures it is negative. Unrecognized assertions will always fail, whether assert or nassert is used. Installations may add their own assertions; this can be used to ensure processes intended only for that site do not affect other sites. If both a positive and negative assertion are specified, then both must succeed.
Example[edit]
Having a 'bot' submit edits to the following URL (plus additional required parameters)
- ... /api.php?action=edit&assert=bot&nassert=exists
will cause it to fail if the account becomes logged out or loses its bot status, or when trying to edit a page that already exists.
Default assertions[edit]
| keyword | meaning |
|---|---|
| user | Verify that bot is logged in, to prevent anonymous edits. |
| bot | Verify that bot is logged in and has a bot flag. |
| true | Always true; nassert=true will fail if the extension is installed. |
| false | Always false; assert=false will fail if the extension is installed. |
| exists | Verify that page exists. Could be useful from other extensions, i.e. adding nassert=exists to the inputbox extension. |
| test | Verify that this wiki allows random testing. Defaults to false, but can be overridden in LocalSettings.php. |
Downloading[edit]
- To download this, issue the following shell command:
svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/AssertEdit/
Download[edit]
You can download the extension directly from the MediaWiki source code repository (browse code). You can get:
- One of the extensions tags
Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag
- Go to the tags list
- Click the name of the tag you want to download
- Click "snapshot"
- The latest version of one of the extensions branches
Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.
- Go to the branches list
- Click the branch name
- Click "snapshot"
- A snapshot made during the release of a MediaWiki version.
This might be unstable and is not guaranteed to work with the associated MediaWiki version.
After you've got the code, save it into the extensions/AssertEdit directory of your wiki.
If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:
cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/AssertEdit.git
Installation[edit]
To install, add a line to your LocalSettings.php like
require_once( "$IP/extensions/AssertEdit/AssertEdit.php" );
New asssertions can then be added with AssertEdit::setAssert(key, value);, where key is the name of the assertion, and value is its value; true means the assertion will succeed, false will fail.
value must either be a boolean (true or false) or a function (as defined by the PHP is_callable() function) which returns a boolean value.
AssertEdit::setAssert will fail if value is of the wrong type, or key corresponds to an assertion that cannot be overridden.
| This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |
| Language: | English • 日本語 |
|---|