手册:钩子/APIEditBeforeSave

This page is a translated version of the page Manual:Hooks/APIEditBeforeSave and the translation is 40% complete.
APIEditBeforeSave
version 1.13.0 版可用
version 1.34.0 (Gerrit change 519797)版被移除
Called right before saving an edit submitted through api.php?action=edit
定义函数:
public static function onAPIEditBeforeSave( $editPage, $text, &$resultArr ) { ... }
附加钩子: extension.json中:
{
	"Hooks": {
		"APIEditBeforeSave": "MediaWiki\\Extension\\MyExtension\\Hooks::onAPIEditBeforeSave"
	}
}
调用自: 文件: api/ApiEditPage.php
介面: APIEditBeforeSaveHook.php

更多有关附加钩子的信息,请参见Manual:Hooks
有关使用此钩子的扩展示例,请参见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.