Open main menu

手册:钩子/APIEditBeforeSave

This page is a translated version of the page Manual:Hooks/APIEditBeforeSave and the translation is 40% complete.
Other languages:
English • ‎中文 • ‎日本語
APIEditBeforeSave
version 1.13.0 版可用
在version 1.34.0
Called right before saving an edit submitted through api.php?action=edit
定义函数:
public static function onAPIEditBeforeSave( $editPage, $text, &$resultArr ) { ... }
附加钩子:

In extension.json:

{
	"Hooks": {
		"APIEditBeforeSave": "MyExtensionHooks::onAPIEditBeforeSave"
	}
}

For MediaWiki ≤1.25:

$wgHooks['APIEditBeforeSave'][] = 'MyExtensionHooks::onAPIEditBeforeSave';
调用自:文件: api/ApiEditPage.php

更多有关附加钩子的信息,请参见手册:钩子
有关使用此钩子的扩展示例,请参见Category:APIEditBeforeSave extensions/zh

细节

  • $editPage: 编辑页面目标
  • $text: the new text of the article (has yet to be saved)
  • $resultArr: data in this array will be added to the API result

注释

Return true to continue processing, return false to abort processing and reject the edit. If $resultArr was filled, the API will return an <edit result="Failure"> element with the contents of $resultArr added in. If $resultArr wasn't filled, the API will return an error message.