API:Filerevert

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

Other languages:
English • ‎dansk • ‎русский • ‎ไทย • ‎中文 • ‎日本語 • ‎한국어

Token

To revert a file to an older version, a CSRF token is required. The CSRF token is the same for all pages, but changes at every login. CSRF tokens can be obtained via action=query&meta=tokens with type=csrf (MW 1.24+). For older versions, you can use API:令牌(操作) or API:Info to get an edit token.

参数

  • filename: 目标文件名,没有File:前缀。
  • archivename: Archive name of the revision to revert to. This should include the timestamp of the revision and the name of the file in the format: yyyyMMddhhmmss!filename. This information can be found using Imageinfo with iilimit set higher than 1. When looking at a file's page, the seconds will not be displayed; the needed archive name can be found by hovering over the older image and looking at the displayed file name. (Note that the ! will already have been urlencoded as %21.)
  • token: A CSRF token obtained as per the Tokens section, above. Take care to urlencode the trailing +\ as %2B%5C.
  • comment: Upload comment.

错误代码

除了通常情况之外:

代码 信息
notanarticle 您请求的页面不存在。
filerevert-badversion 文件并无所请求时间戳下的早期本地版本。

示例

Revert Wiki.png to the version from 15:27:40, 5 March 2011.



action=filerevert

(main | filerevert)
  • This module requires read rights.
  • This module requires write rights.
  • This module only accepts POST requests.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Revert a file to an old version.

Parameters:
filename

Target filename, without the File: prefix.

This parameter is required.
comment

Upload comment.

Default: (empty)
archivename

Archive name of the revision to revert to.

This parameter is required.
token

A "csrf" token retrieved from action=query&meta=tokens

This parameter is required.