API:Schützen

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page API:Protect and the translation is 41% complete.

Other languages:
Deutsch • ‎English • ‎dansk • ‎français • ‎português • ‎română • ‎русский • ‎ไทย • ‎中文 • ‎日本語 • ‎한국어

Token

Um den Schutzstatus einer Seite zu ändern ist ein CSRF-Token erforderlich. Der Token ist für alle Seiten identisch, ändert sich aber nach jedem Login. CSRF-Tokens können über action=query&meta=tokens mit type=csrf erhalten werden (MW 1.24+).

In vorhergehenden Versionen von MediaWiki war ein protect-Token notwendig (Veraltet). Dieser Token ist mit dem edit-Token identisch, gleich für alle Seiten, ändert sich aber nach jedem Login. Protect-Tokens können über API:Tokens mit type=protect (MW 1.20+) oder mit der Folgenden Methode erhalten werden:

Einen protect-Token erhalten (Veraltet)

Seiten schützen

Seiten können mit action=protect geschützt werden.

Parameter

  • title: Die zu schützende Seite.
  • pageid: Die Page-ID (&curid=) der Seite die du schützen willst. Kann nicht zusammen mit title benutzt werden. 1.20+
  • token: Ein CSRF-Token, erhalten mit action=query&meta=tokens (oder wie oben beschrieben)
  • protections: Eine mit Pipes getrennte liste von Schutzstufen, formatiert als action=group, z.B. edit=autoconfirmed|move=sysop
    • If you want to remove a protection, use all as group, e.g. edit=all|move=sysop
    • If you leave out an action, the associated value won't be changed, i.e. edit=sysop leaves the move protection untouched.
  • expiry: Pipe-separated list of expiry timestamps in GNU timestamp format. The first timestamp applies to the first protection in protections, the second to the second, etc. The timestamps infinite, indefinite and never result in a protection that will never expire. Timestamps like next Monday 16:04:57 or 9:28 PM tomorrow are also allowed, see the GNU web site for details.
    • The number of expiry timestamps must equal the number of protections, or you'll get an error message
      • An exception to this rule is made for backwards compatibility: if you specify exactly one expiry timestamp, it'll apply to all protections
    • Not setting this parameter is equivalent to setting it to infinite
  • reason: The reason for the (un)protection (optional).
  • tags: Change tags to apply to the entry in the protection log. 1.27+
  • cascade: If set, pages transcluded in the protected page will also be protected. If the required user level to edit is lower than the required user level to protect (e.g. edit=autoconfirmed), cascading can't be enabled, and this parameter will be silently ignored.
    • The latter is to prevent people who shouldn't be able to protect pages from protecting them anyway by transcluding them in a page with cascading protection.
  • watch: If set, add the page being (un)protected to the current user's watchlist. 1.15+ (veraltet in 1.17)
  • watchlist: Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch. Possible values: watch, unwatch, preferences, nochange (Default: preferences) 1.17+

Beispiele

In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=protect requires POST requests; GET requests will cause an error.

Protecting the Main Page edit=autoconfirmed, move=sysop, the first expiring February 24, 2015 at 12:34:56, the second expiring March 25, 2015 at 13:06:20 with cascading protection enabled.

Protecting "Deletion log" create=sysop, expiring a 2 months from now

Possible errors

In addition to the usual stuff:

Code Info
notitle The title parameter must be set.
notoken The token parameter must be set.
noprotections The protections parameter must be set.
invalidexpiry Expiry time "expiry" is in the past.
This means the expiry timestamp was invalidly formatted, or is nonexistent (like November 31 or 24:05).
pastexpiry Expiry time "expiry" is in the past.
toofewexpiries number expiry timestamps were provided where number2 were needed.
This error is misnamed: it's also thrown when you specify too many expiry times
cantedit You can't protect this page because you can't edit it
create-titleexists Existing titles can't be protected with create.
missingtitle-createonly Missing titles can only be protected with create.
protect-invalidaction Ungültiger Schutztyp „type“.
protect-invalidlevel Invalid protection level "level".